0
0
Nginxdevops~20 mins

Custom config in Docker in Nginx - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Docker Nginx Config Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2: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
ANo container is created
BError: Cannot mount /home/user/nginx.conf because it does not exist
CContainer exits immediately due to config error
DA running container named 'mynginx' listening on port 8080
Attempts:
2 left
💡 Hint
Check if the config file path is correct and the container runs detached.
Configuration
intermediate
2: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?
AADD /etc/nginx/nginx.conf nginx.conf
BCOPY nginx.conf /etc/nginx/nginx.conf
CCOPY /etc/nginx/nginx.conf nginx.conf
DADD nginx.conf /usr/local/nginx/nginx.conf
Attempts:
2 left
💡 Hint
COPY copies from build context to container path.
Troubleshoot
advanced
2:00remaining
Why does nginx fail to start with this Docker volume mount?
You run:
docker run -d -v /home/user/nginx.conf:/etc/nginx/nginx.conf nginx
But the container exits immediately. What is the most likely cause?
AThe host file /home/user/nginx.conf has wrong permissions or is empty
BThe container image does not have nginx installed
CThe port 80 is already in use on the host
DDocker daemon is not running
Attempts:
2 left
💡 Hint
Check the config file content and permissions on the host.
🔀 Workflow
advanced
2: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?
AEdit the config file on the host and send nginx reload signal inside the container
BStop the container, replace the config file inside container, then start it
CRebuild the image with new config and redeploy container
DEdit the config file inside the container directly using docker exec
Attempts:
2 left
💡 Hint
Think about how volume mounts reflect changes and how nginx reload works.
Best Practice
expert
3: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?
ABuild separate Docker images each with its own config baked in
BUse environment variables inside nginx.conf to switch configs dynamically
CUse one image and mount different config files at runtime per environment
DCopy all configs inside one image and switch config by editing container files
Attempts:
2 left
💡 Hint
Consider flexibility and image rebuild overhead.