Creating Isolated Network in Docker
In this guide we will create docker containers on a host and utilize a Custom Bridge Network in order to create isolation between them.
Prerequisites: Docker CLI
The build begins:
First we will create two docker containers. They will be named login and logout respectively. My advice when creating the containers would be to create a new tab in the terminal for each.
To do create a container run the below command:
docker run -d --name <name of the container> nginx:latestIn order to confirm that these two containers can communicate with each other we will login to the login container, installing ping and ping the logout container.
To do this login to the login container by running the command:
docker exec -it login /bin/bashWe will also be updating the container
apt updateNext to provide this container with the capability to ping another we will install the ping command:
apt install iputils-ping -yTo ping the logout container from the login container we will need to the ip-address of the logout container.
To attain this go to another tab and type:
docker inspect logoutIn the above we can see that the ip address is 172.17.0.2.
Using this, return to the login command and send a ping.
Here we see that the login container is able to ping the logout container.
Get Akil Blanchard’s stories in your inbox
Join Medium for free to get updates from this writer.
Now we will create our Custom Bridge Network called ‘secure-network’ and then the finance container.
It is necessary to create the network before the container as we will have to pass in the network name as an attribute when creating the container.
docker network create secure-networkTo then create the container run:
docker run -d --name finance --network=secure-network nginx:latestLet us take a look at the ip address of the finance container:
docker inspect financeHere we can see two main differences: The Network name is secure-network as opposed to bridge and the container has an ip address of 172.20.0.2.
Let us attempt to ping this container from the logout container.
We have no communication between the two as they are isolated from each other.
If you want to see all the networks that are currently running you can do this by running:
docker network lsTo see the running containers:
docker ps







