0
0
Dockerdevops~20 mins

Inspecting container network settings in Docker - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Network Inspector Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Inspect the IP address of a running container
You have a running Docker container named webapp. Which command will show you the container's IP address?
Adocker network inspect webapp
Bdocker logs webapp | grep IP
Cdocker ps -q webapp
Ddocker inspect -f '{{ .NetworkSettings.IPAddress }}' webapp
Attempts:
2 left
💡 Hint
Use the docker inspect command with a format option to get specific network info.
💻 Command Output
intermediate
2:00remaining
Check which network a container is connected to
You want to find out which Docker networks the container dbserver is connected to. Which command gives you this information?
Adocker inspect -f '{{ json .NetworkSettings.Networks }}' dbserver
Bdocker network inspect dbserver
Cdocker network ls dbserver
Ddocker ps --filter network=dbserver
Attempts:
2 left
💡 Hint
Look inside the container's network settings using docker inspect with a format.
Troubleshoot
advanced
3:00remaining
Diagnose why a container cannot reach another container by name
Two containers, frontend and backend, are running on the default bridge network. The frontend container cannot ping backend by its container name. What is the most likely reason?
AThe backend container is stopped, so it cannot respond to pings.
BContainers on the default bridge network cannot resolve each other's names; user-defined networks are needed for name resolution.
CThe frontend container's firewall is blocking ICMP packets.
DDocker daemon is not running, so containers cannot communicate.
Attempts:
2 left
💡 Hint
Think about how Docker handles DNS resolution on different network types.
Configuration
advanced
3:00remaining
Configure a container to use a specific static IP address
You want to run a container with a fixed IP address 172.18.0.50 on a user-defined network named mynetwork. Which command correctly assigns this IP?
Adocker network create --subnet=172.18.0.0/16 mynetwork && docker run --net mynetwork --ip 172.18.0.50 alpine
Bdocker run --net mynetwork --ip 172.18.0.50 alpine
Cdocker network create mynetwork && docker run --net mynetwork --ip 172.18.0.50 alpine
Ddocker run --ip 172.18.0.50 alpine
Attempts:
2 left
💡 Hint
You must create the network with a subnet before assigning static IPs.
Best Practice
expert
4:00remaining
Best practice for inspecting container network settings in a multi-host Docker Swarm
In a Docker Swarm cluster with multiple hosts, you want to inspect the network settings of a service's tasks (containers) across nodes. What is the best approach?
AUse <code>docker service inspect [service]</code> to get all network details of tasks directly from the manager node.
BRun <code>docker network inspect [network]</code> on the manager node only to see all container IPs.
CUse <code>docker service ps --no-trunc --filter desired-state=running [service]</code> to list tasks, then <code>docker inspect</code> on each task container ID on its host.
DSSH into each worker node and run <code>docker ps</code> to find containers, then <code>docker logs</code> for network info.
Attempts:
2 left
💡 Hint
Consider how Docker Swarm distributes containers and where you can run commands.