- Create two alpine containers with default bridge network
- Verify if both containers are associated with bridge network
- Get IP-addresses of both the containers
- Enter into the first container through interactive mode
- ping second container using IP-address
- ping second container using container name
Step 1:
By default all containers will be created under default bridge network
> docker run -itd --name alpine1 alpine> docker run -itd --name alpine2 alpine
Use below command to check both containers are up and running
> docker ps
Step 2:
Use below command to check both containers are associated with bridge network
> docker inspect bridge
Step 3:
use below command to get container IP-address
> docker inspect alpine1
Step 4:
Use below command to enter running container using interactive mode
> docker exec -it alpine1 sh
Step 5:
# ping -c 2 172.17.0.5 (i.e. ping will be successful )
Step 6:
# ping -c 2 alpine2 (i.e. bad address 'alpine2' )
i.e. All the containers under default bridge network will be communicated only by using container IP-address
Happy Coding :)
No comments:
Post a Comment