0
0
Nginxdevops~10 mins

Custom config in Docker in Nginx - 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 run an nginx container with a custom config file.

Nginx
docker run -d -p 8080:80 -v ./mynginx.conf:/etc/nginx/nginx.conf:[1] nginx
Drag options to blanks, or click blank then click option'
Arw
Bcache
Ctmpfs
Dro
Attempts:
3 left
💡 Hint
Common Mistakes
Using :rw allows writing to the config file inside the container, which is usually not needed.
Using :tmpfs or :cache are not valid for mounting regular files.
2fill in blank
medium

Complete the Dockerfile line to copy a custom nginx config into the image.

Nginx
COPY [1] /etc/nginx/nginx.conf
Drag options to blanks, or click blank then click option'
Anginx.conf.default
Bdefault.conf
Cmynginx.conf
Dconf.d/nginx.conf
Attempts:
3 left
💡 Hint
Common Mistakes
Using default or unrelated config filenames that do not exist in the build context.
Copying a directory instead of a single config file.
3fill in blank
hard

Fix the error in the Docker run command to mount a directory with custom configs.

Nginx
docker run -d -p 8080:80 -v [1]:/etc/nginx/conf.d nginx
Drag options to blanks, or click blank then click option'
A./conf.d
Bconf.d
C/conf.d
D/etc/nginx/conf.d
Attempts:
3 left
💡 Hint
Common Mistakes
Using just 'conf.d' without './' may cause Docker to look in the wrong place.
Using container paths as source paths causes errors.
4fill in blank
hard

Fill both blanks to create a Dockerfile snippet that sets the working directory and copies the config.

Nginx
WORKDIR [1]
COPY [2] ./
Drag options to blanks, or click blank then click option'
A/etc/nginx
Bmynginx.conf
C/usr/share/nginx/html
Ddefault.conf
Attempts:
3 left
💡 Hint
Common Mistakes
Setting working directory to the wrong path.
Copying the wrong config filename.
5fill in blank
hard

Fill all three blanks to define a volume for nginx logs and expose port 80 in Docker Compose.

Nginx
version: '3'
services:
  web:
    image: nginx
    ports:
      - '[1]:80'
    volumes:
      - '[2]:/var/log/nginx'
    restart: [3]
Drag options to blanks, or click blank then click option'
A8080
Bnginx-logs
Calways
D80
Attempts:
3 left
💡 Hint
Common Mistakes
Using port 80 on host may conflict with existing services.
Forgetting to define a restart policy causes container to stop on failure.