Docker

How does communication between docker containers take place?

Communication between docker containers

To understand the networking or communication between docker containers make sure you know “what is docker“, “how to run a docker container“, after knowing that you can proceed further.

To start with, we need to first check that whether any of the docker containers are already running or not:

check running docker containers

sudo docker container ls

Container1

Now, we have to run our first docker container by doing the same as shown in the picture below:

run docker container

sudo docker container run -i -t –name container1 alpine ash

From above, we can say that:

Name of the container = “container1

IP address of the container = 172.17.0.2

Container2

Now, we have to create our second container in order to perform and check some options and for better understanding of docker containers.

run a docker container with name

sudo docker container run -i -t –name container2 alpine ash

Name of the container = “container2

IP address of the container = 172.17.0.3

Check Communication using “ping” command

  • We want to check connection from “container1 = 172.17.0.2” to “container2 = 172.17.0.3”
ping a docker container

ping 172.17.0.3

  • We want to check connection from “container2 = 172.17.0.3” to “container1 = 172.17.0.2”
ping a docker container

ping 172.17.0.2

Conclusion

We have seen that both of our containers are communicating with each other perfectly which was our purpose for this post and now with this basic understanding of communication between docker containers can lead us to more complex and advance concepts of docker, stay tuned for more posts like this.

Comment here