Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the command to start a Docker container in detached mode.
Docker
docker run [1] nginx Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '--rm' which removes the container after it stops.
Using '-p' which is for port mapping.
Using '--name' which names the container.
✗ Incorrect
The '-d' flag runs the container in detached mode, allowing it to run in the background.
2fill in blank
mediumComplete the command to map port 8080 on the host to port 80 in the container.
Docker
docker run -p [1]:80 nginx
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the ports and using '80:8080' which maps the wrong way.
Using port 443 which is for HTTPS by default.
Using port 3000 which is unrelated here.
✗ Incorrect
Port 8080 on the host is mapped to port 80 inside the container using '-p 8080:80'.
3fill in blank
hardFix the error in the Dockerfile to set the working directory.
Docker
WORKDIR [1]/app Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the leading slash causing path errors.
Adding trailing slashes inconsistently.
Using relative paths instead of absolute.
✗ Incorrect
The WORKDIR path must be absolute, starting with a slash '/' to avoid errors.
4fill in blank
hardFill both blanks to create a Docker volume mount for persistent data.
Docker
docker run -v [1]:[2] nginx
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping host and container paths.
Using relative paths instead of absolute.
Using system directories that may cause permission issues.
✗ Incorrect
The volume mount syntax is '-v host_path:container_path'. Here, '/host/data' is the host directory and '/container/data' is the container directory.
5fill in blank
hardFill all three blanks to write a Dockerfile command that copies files and sets environment variables.
Docker
COPY [1] [2] ENV [3]=production
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong source or destination paths.
Forgetting to set environment variables correctly.
Mixing up COPY and ADD commands.
✗ Incorrect
The COPY command copies 'src/' directory to '/app/' in the container. ENV sets the environment variable 'NODE_ENV' to 'production'.