0
0
Dockerdevops~20 mins

Running a container with docker run - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Docker Run Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of docker run with port mapping
What will be the output when running this command?
docker run -d -p 8080:80 nginx

Assume no other containers are running and Docker is installed correctly.
AStarts a detached nginx container mapping host port 8080 to container port 80 and outputs the container ID
BStarts nginx container in foreground and outputs nginx logs
CFails with error: port 8080 already in use
DStarts a container but does not map any ports
Attempts:
2 left
💡 Hint
The -d flag runs the container in detached mode, and -p maps ports.
🧠 Conceptual
intermediate
1:30remaining
Purpose of --rm flag in docker run
What does the --rm flag do when used with docker run?
AAutomatically removes the container after it stops
BRestarts the container automatically if it crashes
CRemoves the image after container creation
DRuns the container in read-only mode
Attempts:
2 left
💡 Hint
Think about container cleanup after execution.
Troubleshoot
advanced
2:30remaining
Troubleshooting docker run with volume mount error
You run this command:
docker run -v /host/data:/container/data busybox ls /container/data

But get an empty output even though /host/data has files. What is the likely cause?
AThe container path /container/data is incorrect and should be /data
BThe busybox image does not support volume mounts
C/host/data path does not exist or is empty on the host
DDocker daemon is not running
Attempts:
2 left
💡 Hint
Check the host directory before running the container.
🔀 Workflow
advanced
3:00remaining
Correct order to run a container with environment variables and port mapping
Arrange these steps in the correct order to run a container with environment variable MY_VAR=hello and map port 5000 to 80:
A1,3,2,4
B3,1,2,4
C2,1,3,4
D1,2,3,4
Attempts:
2 left
💡 Hint
You must have the image before running the container.
Best Practice
expert
3:00remaining
Best practice for running containers with sensitive environment variables
Which option is the best practice to securely pass sensitive environment variables like passwords to a container using docker run?
AUse docker run -e PASSWORD=secret directly in the command line
BStore sensitive variables in a file and use --env-file option with docker run
CHardcode sensitive variables inside the Dockerfile ENV instruction
DPass sensitive variables as command arguments inside the container
Attempts:
2 left
💡 Hint
Think about avoiding exposure in command history or image layers.