Challenge - 5 Problems
Container DNS Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Docker container DNS resolution output
You have two Docker containers running on the same user-defined bridge network named
mynetwork. Container A tries to ping Container B using its container name. What will be the output of the ping command inside Container A?Docker
docker network create mynetwork docker run -dit --name containerB --network mynetwork alpine sh docker run -dit --name containerA --network mynetwork alpine sh docker exec containerA ping -c 1 containerB
Attempts:
2 left
💡 Hint
Containers on the same user-defined bridge network can resolve each other by container name.
✗ Incorrect
Docker user-defined bridge networks provide built-in DNS resolution. Containers can reach each other by their container names as hostnames.
🧠 Conceptual
intermediate1:30remaining
Service discovery mechanism in Docker Swarm
Which of the following best describes how service discovery works in Docker Swarm mode?
Attempts:
2 left
💡 Hint
Think about how Docker Swarm manages multiple replicas of a service.
✗ Incorrect
Docker Swarm includes an internal DNS server that automatically resolves service names to the IP addresses of the running tasks, enabling easy service discovery.
❓ Troubleshoot
advanced2:00remaining
Troubleshooting container DNS failure on default bridge network
You run two containers on the default Docker bridge network. Container A tries to ping Container B by its container name but fails with
ping: unknown host containerB. What is the most likely cause?Attempts:
2 left
💡 Hint
Consider the difference between default and user-defined bridge networks.
✗ Incorrect
The default bridge network does not provide automatic DNS resolution by container name. Only user-defined bridge networks support this feature.
🔀 Workflow
advanced1:30remaining
Configuring service discovery with Docker Compose
Given the following Docker Compose snippet, what hostname should
web service use to connect to the db service?Docker
version: '3.8'
services:
web:
image: nginx
depends_on:
- db
db:
image: mysql
environment:
MYSQL_ROOT_PASSWORD: exampleAttempts:
2 left
💡 Hint
Services in the same Docker Compose network can reach each other by service name.
✗ Incorrect
Docker Compose creates a default network where services can resolve each other by their service names as hostnames.
✅ Best Practice
expert2:30remaining
Best practice for service discovery in multi-host Docker environments
In a multi-host Docker environment without Swarm, which approach is best to enable reliable service discovery across hosts?
Attempts:
2 left
💡 Hint
Think about scalability and automation in multi-host setups.
✗ Incorrect
Docker's default networking does not support cross-host DNS resolution without orchestration. External tools like Consul or etcd provide scalable, automated service discovery.