0
0
Nginxdevops~10 mins

Official Nginx Docker image - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the Docker command to pull the official Nginx image from Docker Hub.

Nginx
docker [1] nginx
Drag options to blanks, or click blank then click option'
Arun
Bpull
Cpush
Dbuild
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'run' instead of 'pull' will try to start a container but fail if image is missing.
Using 'push' tries to upload an image, not download.
2fill in blank
medium

Complete the Docker command to start a container named 'webserver' from the official Nginx image, mapping port 8080 on the host to port 80 in the container.

Nginx
docker run -d --name webserver -p [1]:80 nginx
Drag options to blanks, or click blank then click option'
A8080
B80
C443
D8000
Attempts:
3 left
💡 Hint
Common Mistakes
Using 80:80 maps the same port, not 8080.
Using 443 is for HTTPS, not requested here.
3fill in blank
hard

Fix the error in the Dockerfile line to use the official Nginx image as base.

Nginx
FROM [1]
Drag options to blanks, or click blank then click option'
Aofficial/nginx
Bnginx/latest
Cnginx:latest
Ddocker/nginx
Attempts:
3 left
💡 Hint
Common Mistakes
Using slash instead of colon causes Dockerfile build errors.
Using non-existent image names causes build failure.
4fill in blank
hard

Fill both blanks to create a Docker command that runs Nginx in detached mode and removes the container after it stops.

Nginx
docker run [1] [2] nginx
Drag options to blanks, or click blank then click option'
A-d
B-rm
C--rm
D-it
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-rm' instead of '--rm' causes an error.
Using '-it' is for interactive mode, not detached.
5fill in blank
hard

Fill all three blanks to create a Docker command that runs Nginx, names the container 'mynginx', maps port 8081 on host to 80 in container, and mounts local directory '/home/user/site' to '/usr/share/nginx/html' inside container.

Nginx
docker run -d --name [1] -p [2]:80 -v [3]:/usr/share/nginx/html nginx
Drag options to blanks, or click blank then click option'
Amynginx
B8081
C/home/user/site
D/var/www/html
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping host and container ports in -p flag.
Using wrong local directory path for volume mount.