Saturday, April 18, 2020

Docker Assignments #1 : Default Bridge Network


  1. Create two alpine containers with default bridge network
  2. Verify if both containers are associated with bridge network
  3. Get IP-addresses of both the containers
  4. Enter into the first container through interactive mode
  5. ping second container using IP-address 
  6. 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
     > docker inspect alpine2

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