0
0
Nginxdevops~20 mins

Container networking in Nginx - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Container Networking Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Check container network interfaces
You run docker exec mynginx ip addr show inside a running nginx container. What output will you see related to network interfaces?
AShows only <code>lo</code> interface with no IP addresses
BLists interfaces including <code>eth0</code> with an IP address assigned by Docker bridge network
CShows <code>wlan0</code> interface with the host Wi-Fi IP address
DReturns an error because <code>ip</code> command is not available in nginx container
Attempts:
2 left
💡 Hint
Docker containers usually have a virtual Ethernet interface named eth0 connected to a bridge network.
🧠 Conceptual
intermediate
2:00remaining
Docker container port exposure
You run an nginx container with docker run -d -p 8080:80 nginx. What does this command do regarding container networking?
ABlocks all network traffic to container port 80
BExposes container port 8080 to host port 80, allowing access via localhost:80
CMaps host port 8080 to container port 80, allowing access to nginx via localhost:8080
DRuns nginx on host network directly without isolation
Attempts:
2 left
💡 Hint
The -p flag maps host ports to container ports.
Troubleshoot
advanced
2:00remaining
Container cannot reach external internet
An nginx container cannot access the internet to download updates. Which Docker network setting is most likely causing this?
AContainer has <code>--net=none</code> which disables all networking
BContainer is running with <code>--network host</code> which disables internet access
CContainer is using the default bridge network which blocks all outbound traffic
DContainer is attached to a user-defined bridge network without proper DNS or gateway settings
Attempts:
2 left
💡 Hint
Check if the container has any network interfaces enabled.
🔀 Workflow
advanced
2:00remaining
Connecting two containers on the same user-defined network
You have two containers, web and db, on the same Docker user-defined bridge network named mynetwork. How can web container reach db by hostname?
AUse <code>db</code> as the hostname in the <code>web</code> container to connect to the <code>db</code> container
BUse the IP address of <code>db</code> container only, hostnames are not resolved
CUse <code>localhost</code> inside <code>web</code> container to reach <code>db</code>
DUse the host machine IP address to connect from <code>web</code> to <code>db</code>
Attempts:
2 left
💡 Hint
User-defined bridge networks provide automatic DNS resolution between containers.
Best Practice
expert
2:00remaining
Securing container network traffic
Which practice best improves security for container network traffic in a production environment?
AUse the default bridge network for all containers to reduce complexity
BExpose all container ports to the host to monitor traffic easily
CDisable Docker network isolation to simplify network setup
DUse encrypted overlay networks or VPNs between Docker hosts to protect container traffic
Attempts:
2 left
💡 Hint
Think about encrypting data in transit between containers on different hosts.