Challenge - 5 Problems
Detached Mode Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of running a container with detached mode?
You run the command
docker run -d nginx. What will the output be?Docker
docker run -d nginxAttempts:
2 left
💡 Hint
Detached mode runs the container in the background and prints the container ID.
✗ Incorrect
When you run a container with the -d flag, Docker starts it in the background and prints the container ID. It does not show logs or HTML output.
🧠 Conceptual
intermediate2:00remaining
Why use detached mode when running containers?
Which reason best explains why detached mode (-d) is used when running Docker containers?
Attempts:
2 left
💡 Hint
Detached mode frees up your terminal by running the container in the background.
✗ Incorrect
Detached mode allows the container to run in the background, so you can continue using the terminal without being attached to the container's output.
❓ Troubleshoot
advanced2:00remaining
Why does
docker run -d fail with 'no tty present' error?You run
docker run -d -it ubuntu but get an error: 'the input device is not a TTY'. What is the cause?Attempts:
2 left
💡 Hint
Detached mode means no terminal attached, but -t requests a terminal.
✗ Incorrect
The -d flag runs the container detached (no terminal), but -t requests a terminal allocation. These conflict and cause the error.
🔀 Workflow
advanced3:00remaining
What is the correct sequence to run a container detached and then view its logs?
Arrange the commands in the correct order to run an nginx container detached and then see its logs.
Attempts:
2 left
💡 Hint
You must run the container first, check it's running, then view logs, then stop it.
✗ Incorrect
First, run the container detached. Then list running containers to confirm. Next, view logs. Finally, stop the container.
✅ Best Practice
expert2:30remaining
Which command correctly runs a container detached with port mapping and environment variable?
You want to run a container detached, map port 8080 on host to 80 in container, and set ENV VAR=prod. Which command is correct?
Attempts:
2 left
💡 Hint
Check the order and syntax of flags for port and environment variables.
✗ Incorrect
Option C uses correct flags: -d for detached, -p hostPort:containerPort, and -e for environment variable with correct syntax.