[Docker] Getting Started with Container Networks

时间:2023-03-09 07:08:01
[Docker] Getting Started with Container Networks

It is possible to group containers into a network and we can create multi networks so that container in each isolated network can communiate with each other, but we can fine control the access right by using network, how containers communiate should happen inside network.

[Docker] Getting Started with Container Networks

In this post, we are going to see how to create a network and how to run a container inside a network.

Create a network:

docker network create --driver bridge isolated_network

[Docker] Getting Started with Container Networks

Run containers in the Container Network

docker run -d --net=isolated_network --name mongodb mongo

[Docker] Getting Started with Container Networks

Give every container you want to link into the network a name.
in next post, we will see how to do it in a real world example