0
0
Nginxdevops~20 mins

Official Nginx Docker image - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Nginx Docker Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
Nginx container startup log
You run the command docker run --name webserver -d nginx. What is the expected output of docker logs webserver?
Anginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
B
2024/01/01 00:00:00 [notice] 1#1: using the "epoll" event method
2024/01/01 00:00:00 [notice] 1#1: nginx/1.25.0
2024/01/01 00:00:00 [notice] 1#1: start worker processes
2024/01/01 00:00:00 [notice] 1#1: start worker process 7
C
Error: Cannot find image 'nginx:latest' locally
Pulling from library/nginx
Digest: sha256:abcdef1234567890
Status: Downloaded newer image for nginx:latest
Ddocker: command not found
Attempts:
2 left
💡 Hint
Check the typical startup log messages for the official Nginx container.
Configuration
intermediate
1:30remaining
Mounting custom Nginx config in Docker
You want to run the official Nginx Docker container with your own nginx.conf file located at /home/user/nginx.conf. Which docker run command correctly mounts this config to override the default?
Adocker run -d -p 80:80 -v /home/user/nginx.conf:/etc/nginx/conf.d/nginx.conf:ro nginx
Bdocker run -d -p 80:80 -v /etc/nginx/nginx.conf:/home/user/nginx.conf:ro nginx
Cdocker run -d -p 80:80 -v /home/user/nginx.conf:/usr/local/nginx/conf/nginx.conf:ro nginx
Ddocker run -d -p 80:80 -v /home/user/nginx.conf:/etc/nginx/nginx.conf:ro nginx
Attempts:
2 left
💡 Hint
The official Nginx image expects the main config at /etc/nginx/nginx.conf.
Troubleshoot
advanced
1:30remaining
Nginx container fails to start with port binding error
You run docker run -d -p 80:80 nginx but the container exits immediately. Checking logs shows:
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
What is the most likely cause?
AThe Docker daemon is not running
BThe container lacks permission to bind to port 80 inside the container
CAnother process on the host is already using port 80
DThe Docker image is corrupted and missing Nginx binaries
Attempts:
2 left
💡 Hint
Port binding errors usually mean the port is busy on the host machine.
🔀 Workflow
advanced
2:00remaining
Updating Nginx container with zero downtime
You have a running Nginx container named webserver. You want to update it to a newer Nginx image version without downtime. Which workflow is best?
APull new image, start new container on different ports, switch traffic via load balancer, then stop old container
BPull new image, stop current container, start new container with same ports and volumes
CRemove old container, pull new image, start new container with same ports
DRestart Docker daemon, then pull new image and start new container
Attempts:
2 left
💡 Hint
Zero downtime means traffic must not be interrupted during update.
Best Practice
expert
2:00remaining
Securing Nginx Docker container with least privileges
Which practice best improves security by running the official Nginx Docker container with least privileges?
AUse the <code>--user</code> flag to run Nginx as a non-root user inside the container
BRun the container as root user to avoid permission issues
CDisable all logging to prevent sensitive data exposure
DRun the container with <code>--privileged</code> flag for full access
Attempts:
2 left
💡 Hint
Running as non-root inside containers is a common security best practice.