- Nikhil Bhaskar
- July 8, 2021
Docker is a open-source platform. We can create, modify, push & pull the images. It is used for developing, shipping, and running applications.
It is a platform that enables developers to build, deploy, run, update, and stop containers using simple commands.
Install Docker & Create a Docker Image
- We can install docker so click on link https://www.hackerxone.com/blog/how-install-docker-ubuntu-2004-lts for hot to install docker on ubuntu 20.04.
- We needs Two docker images for communication so click on link https://www.hackerxone.com/blog/how-create-docker-image-pushed-docker-hub-or-amazon-elastic-registry
- Now two docker images is ready.
Connect one docker image to another docker images.
Create two containers:
docker run -d --name container-name1 -p 8001:80 image1
docker run -d --name container-name2 -p 8002:80 image2
We can also link one contianer to another container.
docker run --name container-name2 --link container-name1 image2
Create a new network:
docker network create network-name
Connect Both containers to the network:
docker network connect network-name container-name1
docker network connect network-name container-name2
Check if both containers are part of the new network:
docker network inspect network-name
Before try to make the ping, we should install iputils-ping in the container to make it work.
Update the system.
apt-get install iputils-ping
Now Run the ping command for test the connection:
docker exec -ti container-name1 ping container-name2
docker exec -it image_name1 ping image_name2