0
0
Dockerdevops~10 mins

DNS resolution between containers in Docker - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the command to create a Docker network named 'mynetwork'.

Docker
docker network create [1]
Drag options to blanks, or click blank then click option'
Abridge
Bdefault
Cmynetwork
Dhost
Attempts:
3 left
💡 Hint
Common Mistakes
Using default network names like 'bridge' or 'host' which are predefined.
2fill in blank
medium

Complete the command to run a container named 'web' attached to the 'mynetwork' network.

Docker
docker run -d --name web --network [1] nginx
Drag options to blanks, or click blank then click option'
Abridge
Bmynetwork
Chost
Dnone
Attempts:
3 left
💡 Hint
Common Mistakes
Using default networks like 'bridge' which may not support container name resolution as expected.
3fill in blank
hard

Fix the error in the command to ping the 'web' container from another container on the same network.

Docker
docker run --rm --network mynetwork alpine ping -c 3 [1]
Drag options to blanks, or click blank then click option'
Aweb
Blocalhost
C127.0.0.1
Dgoogle.com
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'localhost' or '127.0.0.1' which refer to the current container itself.
4fill in blank
hard

Fill both blanks to create a Docker Compose service named 'db' using the 'mysql' image and connect it to the 'mynetwork' network.

Docker
services:
  db:
    image: mysql
    networks:
      - [1]
networks:
  [2]:
Drag options to blanks, or click blank then click option'
Amynetwork
Bdefault
Dbridge
Attempts:
3 left
💡 Hint
Common Mistakes
Using different network names in the two places causing network mismatch.
5fill in blank
hard

Fill all three blanks to define a Docker Compose service 'app' that depends on 'db', uses the 'mynetwork' network, and sets an environment variable 'DB_HOST' to the 'db' service name.

Docker
services:
  app:
    image: myapp
    depends_on:
      - [1]
    environment:
      - DB_HOST=[2]
    networks:
      - [3]
Drag options to blanks, or click blank then click option'
Adb
Cmynetwork
Ddefault
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect service names or default networks that break DNS resolution.