Challenge - 5 Problems
Docker Nginx Config Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this Docker command?
You run this command to start an nginx container with a custom config file mounted. What will be the output of
docker ps immediately after?Nginx
docker run -d --name mynginx -v /home/user/nginx.conf:/etc/nginx/nginx.conf:ro -p 8080:80 nginx
Attempts:
2 left
💡 Hint
Check if the config file path is correct and the container runs detached.
✗ Incorrect
The command runs nginx detached with a custom config file mounted read-only. If the file exists and is valid, the container runs and listens on port 8080.
❓ Configuration
intermediate2:00remaining
Which Dockerfile snippet correctly copies a custom nginx config?
You want to build a Docker image that uses your custom nginx.conf file inside the container at /etc/nginx/nginx.conf. Which snippet is correct?
Attempts:
2 left
💡 Hint
COPY copies from build context to container path.
✗ Incorrect
COPY copies the local file nginx.conf to the container path /etc/nginx/nginx.conf. ADD syntax is similar but less preferred here.
❓ Troubleshoot
advanced2:00remaining
Why does nginx fail to start with this Docker volume mount?
You run:
But the container exits immediately. What is the most likely cause?
docker run -d -v /home/user/nginx.conf:/etc/nginx/nginx.conf nginxBut the container exits immediately. What is the most likely cause?
Attempts:
2 left
💡 Hint
Check the config file content and permissions on the host.
✗ Incorrect
If the config file is empty or unreadable, nginx fails to start and container exits immediately.
🔀 Workflow
advanced2:00remaining
What is the correct workflow to update nginx config in a running container?
You have a running nginx container with a custom config mounted from the host. You want to update the config and apply changes without restarting the container. What should you do?
Attempts:
2 left
💡 Hint
Think about how volume mounts reflect changes and how nginx reload works.
✗ Incorrect
Editing the host file updates the mounted config immediately. Sending nginx reload signal applies changes without downtime.
✅ Best Practice
expert3:00remaining
Which approach is best for managing multiple custom nginx configs in Docker for different environments?
You have dev, staging, and production environments each needing different nginx configs. Which is the best Docker setup?
Attempts:
2 left
💡 Hint
Consider flexibility and image rebuild overhead.
✗ Incorrect
Mounting different config files at runtime allows one image to be reused across environments without rebuilding.