Challenge - 5 Problems
Docker Compose Nginx Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Nginx container port exposure
You run a Docker Compose setup with Nginx service exposing port 80. What is the output of
docker-compose ps regarding the ports column?Nginx
version: '3.8' services: web: image: nginx:latest ports: - "8080:80"
Attempts:
2 left
💡 Hint
Remember the format is host_port:container_port
✗ Incorrect
The ports mapping in Docker Compose maps host port 8080 to container port 80, so the output shows 0.0.0.0:8080->80/tcp.
❓ Configuration
intermediate2:00remaining
Correct Nginx service restart policy in Docker Compose
Which restart policy ensures the Nginx container restarts automatically only if it crashes, but not if stopped manually?
Attempts:
2 left
💡 Hint
Think about restart only on crashes, not manual stops.
✗ Incorrect
The 'on-failure' policy restarts the container only if it exits with a failure code, not if stopped manually.
❓ Troubleshoot
advanced2:00remaining
Nginx container fails to start due to port conflict
You have this Docker Compose snippet for Nginx:
ports: - "80:80"But the container fails to start with an error about port 80. What is the most likely cause?
Attempts:
2 left
💡 Hint
Check what else might be using port 80 on your computer.
✗ Incorrect
If host port 80 is already in use by another process, Docker cannot bind it for the container, causing startup failure.
🔀 Workflow
advanced2:00remaining
Order of commands to update Nginx container with new config
You updated the Nginx config file on your host. Which sequence of commands correctly applies the changes to the running container using Docker Compose?
Attempts:
2 left
💡 Hint
You only changed config, not the image.
✗ Incorrect
Restarting the container reloads the config without rebuilding or stopping the whole stack.
✅ Best Practice
expert2:00remaining
Best way to persist Nginx logs in Docker Compose
You want to keep Nginx logs on the host machine so they are not lost when the container is removed. Which Docker Compose volume configuration is best?
Attempts:
2 left
💡 Hint
Map a host folder to container log folder.
✗ Incorrect
Mapping a host folder (like ./logs) to /var/log/nginx in the container keeps logs on the host persistently.