What command shows the list of Docker networks on your system?
Use docker network ls to see all Docker networks available on your system.
Click to reveal answer
beginner
How can you inspect details of a specific Docker network?
Use docker network inspect <network_name> to see detailed information about a Docker network, including connected containers and IP ranges.
Click to reveal answer
intermediate
What is the purpose of the docker exec command in network debugging?
docker exec lets you run commands inside a running container. You can use it to run network tools like ping or curl inside the container to test connectivity.
Click to reveal answer
intermediate
How do you test if a container can reach another container by name?
Inside one container, use ping <other_container_name> or curl http://<other_container_name> to check if the network name resolution and connectivity work.
Click to reveal answer
intermediate
What common issue can cause containers not to communicate on a user-defined Docker network?
Containers must be connected to the same user-defined network to communicate by name. If they are on different networks or the default bridge network, name resolution may fail.
Click to reveal answer
Which command lists all Docker networks?
Adocker container ls
Bdocker network ls
Cdocker network inspect
Ddocker ps
✗ Incorrect
docker network ls shows all Docker networks. Other commands list containers or inspect networks.
How do you run a ping command inside a running container named webapp?
Adocker run webapp ping google.com
Bdocker network ping webapp google.com
Cdocker start webapp ping google.com
Ddocker exec webapp ping google.com
✗ Incorrect
docker exec webapp ping google.com runs ping inside the running container named webapp.
If two containers cannot reach each other by name, what is a likely cause?
ADocker daemon is stopped
BThey have the same IP address
CThey are on different Docker networks
DContainers are not running
✗ Incorrect
Containers must be on the same user-defined network to resolve each other's names.
Which command shows detailed info about a Docker network named mynetwork?
Adocker network inspect mynetwork
Bdocker network ls mynetwork
Cdocker inspect mynetwork
Ddocker network show mynetwork
✗ Incorrect
docker network inspect mynetwork shows detailed info about the network.
What tool can you use inside a container to test HTTP connectivity?
Acurl
Bping
Cdocker exec
Ddocker network ls
✗ Incorrect
curl tests HTTP connectivity inside a container.
Explain the steps you would take to debug why two Docker containers cannot communicate over the network.
Think about checking container status, network membership, and testing connectivity inside containers.
You got /5 concepts.
Describe how Docker network name resolution works and why it might fail.
Focus on network types and how Docker handles container names.
You got /5 concepts.
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
Step 1: Identify the command to list networks
The command docker network ls lists all Docker networks and their status.
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.
Final Answer:
docker network ls -> Option C
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
Step 1: Understand the purpose of docker exec
docker exec runs commands inside an existing container. The syntax is docker exec [container] [command].
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.
Final Answer:
docker exec webapp ping -c 4 google.com -> Option A
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
Step 1: Understand the error 'ping: command not found'
This means the ping tool is missing inside the container's OS.
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.
Final Answer:
Install ping inside the container or use docker exec app apt-get update && apt-get install iputils-ping. -> Option D
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
Step 1: Understand Docker network name resolution
Containers on the same user-defined network can resolve each other by container name automatically.
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.
Step 3: Avoid deprecated or less flexible methods
Using --link is deprecated and default bridge network does not support automatic name resolution.
Final Answer:
Ensure both containers are connected to the same user-defined network mynetwork and use container names for communication. -> Option B
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 unknownstrongwhile earning +1 Grip toward your certificate.