Bird
Raised Fist0
Dockerdevops~20 mins

Debugging network issues in Docker - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Network Debugging Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Identify the output of a Docker network inspect command
What is the output of the following command when run on a Docker network named my_bridge that has two containers connected?
Docker
docker network inspect my_bridge
AError: No such network: my_bridge
B[{"Name":"my_bridge","Id":"abc123","Containers":{}}]
C[{"Name":"bridge","Id":"abc123","Containers":{"container1":{"Name":"web","IPv4Address":"172.18.0.2/16"}}}]
D[{"Name":"my_bridge","Id":"abc123","Containers":{"container1":{"Name":"web","IPv4Address":"172.18.0.2/16"},"container2":{"Name":"db","IPv4Address":"172.18.0.3/16"}}}]
Attempts:
2 left
💡 Hint
Check the network name and container connections.
❓ Troubleshoot
intermediate
2:00remaining
Troubleshoot container connectivity failure
A container cannot reach another container by its service name on a user-defined Docker network. Which of the following is the most likely cause?
AThe containers have the same IP address assigned manually.
BThe containers are on different user-defined networks without a shared network.
CThe Docker daemon is not running.
DThe container's CPU limit is too low.
Attempts:
2 left
💡 Hint
Service name resolution works only within the same user-defined network.
❓ Configuration
advanced
2:00remaining
Correct Docker Compose network configuration for service communication
Given this Docker Compose snippet, which option correctly configures the network so that app and db services can communicate by service name?
Docker
version: '3.8'
services:
  app:
    image: myapp
    networks:
      - backend
  db:
    image: postgres
    networks:
      - backend
networks:
  backend:
    driver: bridge
AKeep the configuration as is; both services are on the same user-defined network 'backend'.
BRemove the networks section; Docker Compose will use the default network automatically.
CChange the network driver to 'host' to allow communication.
DAssign static IPs to both services on different networks.
Attempts:
2 left
💡 Hint
User-defined bridge networks enable service name resolution.
✅ Best Practice
advanced
2:00remaining
Best practice for isolating container network traffic
Which option is the best practice to isolate network traffic between two groups of containers in Docker?
ACreate two separate user-defined bridge networks and connect containers to their respective networks.
BUse the default bridge network and rely on container names for isolation.
CAssign all containers to the host network driver.
DUse static IP addresses on the default network to separate traffic.
Attempts:
2 left
💡 Hint
User-defined networks provide better isolation than the default bridge.
🔀 Workflow
expert
3:00remaining
Order the steps to debug a Docker container network connectivity issue
Put these steps in the correct order to debug why a container cannot reach another container by service name on a user-defined network.
A2,1,4,3
B2,3,1,4
C1,2,3,4
D1,2,4,3
Attempts:
2 left
💡 Hint
Start by verifying network membership before testing connectivity and DNS.

Practice

(1/5)
1. What is the primary Docker command to list all networks and check their status?
easy
A. docker ps -a
B. docker container ls
C. docker network ls
D. docker inspect network

Solution

  1. Step 1: Identify the command to list networks

    The command docker network ls lists all Docker networks and their status.
  2. Step 2: Differentiate from container commands

    docker container ls and docker ps -a list containers, not networks. docker inspect network is incomplete and incorrect syntax.
  3. Final Answer:

    docker network ls -> Option C
  4. Quick Check:

    List networks = docker network ls [OK]
Hint: Use 'docker network ls' to see all networks quickly [OK]
Common Mistakes:
  • Confusing container list commands with network commands
  • Using incomplete or wrong inspect syntax
  • Trying to check networks with 'docker ps'
2. Which command syntax correctly runs a ping test inside a running container named webapp?
easy
A. docker exec webapp ping -c 4 google.com
B. docker run webapp ping google.com -c 4
C. docker exec -it ping webapp google.com
D. docker ping exec webapp google.com

Solution

  1. Step 1: Understand the purpose of docker exec

    docker exec runs commands inside an existing container. The syntax is docker exec [container] [command].
  2. Step 2: Check the correct ping command format

    ping -c 4 google.com sends 4 ping packets. docker exec webapp ping -c 4 google.com uses correct syntax. Options A, B, and C misuse docker run or command order.
  3. Final Answer:

    docker exec webapp ping -c 4 google.com -> Option A
  4. Quick Check:

    Run ping inside container = docker exec [container] ping [options] [OK]
Hint: Use 'docker exec <container> ping -c 4 <host>' to test connectivity [OK]
Common Mistakes:
  • Using 'docker run' instead of 'docker exec' for existing containers
  • Incorrect order of command arguments
  • Missing '-c' option for ping count
3. You run docker network inspect bridge and see containers connected with IPs. What does this output tell you?
medium
A. It shows which containers are connected to the default bridge network and their IP addresses.
B. It lists all running containers and their CPU usage.
C. It displays the Docker daemon logs for network errors.
D. It shows the firewall rules blocking container traffic.

Solution

  1. Step 1: Understand 'docker network inspect bridge'

    This command shows detailed info about the 'bridge' network, including connected containers and their IPs.
  2. Step 2: Differentiate from other outputs

    It does not show container CPU usage, daemon logs, or firewall rules. Those require other commands.
  3. Final Answer:

    It shows which containers are connected to the default bridge network and their IP addresses. -> Option A
  4. Quick Check:

    Network inspect = container connections + IPs [OK]
Hint: Inspect bridge network to see container IPs and connections [OK]
Common Mistakes:
  • Confusing network inspect with container stats
  • Expecting logs or firewall info from network inspect
  • Misreading IP info as CPU or memory data
4. A container cannot reach the internet. You try docker exec app ping 8.8.8.8 but get 'ping: command not found'. What is the best next step?
medium
A. Run docker network disconnect bridge app to reset network.
B. Restart the Docker daemon with systemctl restart docker immediately.
C. Remove and recreate the container without any changes.
D. Install ping inside the container or use docker exec app apt-get update && apt-get install iputils-ping.

Solution

  1. Step 1: Understand the error 'ping: command not found'

    This means the ping tool is missing inside the container's OS.
  2. Step 2: Fix by installing ping inside the container

    Use package manager commands inside the container to install ping, e.g., apt-get install iputils-ping.
  3. Final Answer:

    Install ping inside the container or use docker exec app apt-get update && apt-get install iputils-ping. -> Option D
  4. Quick Check:

    Missing ping tool = install it inside container [OK]
Hint: If ping missing, install it inside container first [OK]
Common Mistakes:
  • Restarting Docker daemon without checking container tools
  • Removing container without diagnosing issue
  • Disconnecting network without confirming problem source
5. You have two containers, frontend and backend, on a user-defined Docker network mynetwork. The frontend cannot connect to backend by container name. What is the best way to fix this?
hard
A. Use the default bridge network instead of a user-defined network for better name resolution.
B. Ensure both containers are connected to the same user-defined network mynetwork and use container names for communication.
C. Add --link backend option when starting the frontend container to enable name resolution.
D. Restart Docker daemon to refresh network settings.

Solution

  1. Step 1: Understand Docker network name resolution

    Containers on the same user-defined network can resolve each other by container name automatically.
  2. Step 2: Verify both containers are on the same network

    If frontend cannot reach backend by name, likely they are not on the same network. Connect both to mynetwork.
  3. Step 3: Avoid deprecated or less flexible methods

    Using --link is deprecated and default bridge network does not support automatic name resolution.
  4. Final Answer:

    Ensure both containers are connected to the same user-defined network mynetwork and use container names for communication. -> Option B
  5. Quick Check:

    Same user network = container name resolution works [OK]
Hint: Connect containers to same user network for name resolution [OK]
Common Mistakes:
  • Using default bridge network expecting name resolution
  • Relying on deprecated --link option
  • Restarting Docker daemon without checking network setup
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard