Challenge - 5 Problems
Docker Run Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of docker run with port mapping
What will be the output when running this command?
Assume no other containers are running and Docker is installed correctly.
docker run -d -p 8080:80 nginx
Assume no other containers are running and Docker is installed correctly.
Attempts:
2 left
💡 Hint
The -d flag runs the container in detached mode, and -p maps ports.
✗ Incorrect
The command runs nginx detached (-d) and maps host port 8080 to container port 80 (-p 8080:80). Docker outputs the container ID on success.
🧠 Conceptual
intermediate1:30remaining
Purpose of --rm flag in docker run
What does the --rm flag do when used with docker run?
Attempts:
2 left
💡 Hint
Think about container cleanup after execution.
✗ Incorrect
The --rm flag tells Docker to delete the container once it stops running, keeping the system clean.
❓ Troubleshoot
advanced2:30remaining
Troubleshooting docker run with volume mount error
You run this command:
But get an empty output even though /host/data has files. What is the likely cause?
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?
Attempts:
2 left
💡 Hint
Check the host directory before running the container.
✗ Incorrect
If the host directory is empty or missing, the container will show empty contents at the mount point.
🔀 Workflow
advanced3: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:
Attempts:
2 left
💡 Hint
You must have the image before running the container.
✗ Incorrect
First pull the image, then run with options, check running containers, then verify env variable inside.
✅ Best Practice
expert3: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?
Attempts:
2 left
💡 Hint
Think about avoiding exposure in command history or image layers.
✗ Incorrect
Using --env-file keeps sensitive data out of command history and Dockerfile, improving security.