Challenge - 5 Problems
Docker Attach Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
Output of attaching to a running container
You have a running Docker container named
webapp that outputs logs continuously. What will be the output of the command docker attach webapp?Docker
docker attach webappAttempts:
2 left
💡 Hint
Think about what
docker attach does to a running container.✗ Incorrect
The docker attach command connects your terminal to the standard input, output, and error streams of a running container. This means you see the live output and can interact if the container accepts input.
💻 Command Output
intermediate2:00remaining
Effect of detaching from a container
You attached to a running container using
docker attach mycontainer. Which key sequence will safely detach your terminal without stopping the container?Attempts:
2 left
💡 Hint
Detaching requires a special key sequence to avoid stopping the container.
✗ Incorrect
The key sequence Ctrl+P followed by Ctrl+Q detaches your terminal from the container without stopping it. Other sequences may stop or suspend the container.
❓ Troubleshoot
advanced2:00remaining
Troubleshooting attach failure
You run
docker attach myapp but get the error: you cannot attach to a stopped container. What is the most likely cause?Attempts:
2 left
💡 Hint
Check the container status before attaching.
✗ Incorrect
You cannot attach to a container that is stopped. You must start the container first with docker start myapp.
✅ Best Practice
advanced2:00remaining
Best practice for interactive container sessions
Which command is best to start a new container and attach to it interactively with a terminal session?
Attempts:
2 left
💡 Hint
Think about starting and attaching in one step with a terminal.
✗ Incorrect
The -it flags start a container interactively with a terminal attached. The -d flag runs detached (in background).
🔀 Workflow
expert3:00remaining
Correct workflow to attach and detach safely
Arrange the steps in the correct order to attach to a running container named
db, interact with it, and then detach safely without stopping it.Attempts:
2 left
💡 Hint
Think about the natural order of attaching, using, detaching, and returning.
✗ Incorrect
First attach to the container, then interact, then detach safely with the key sequence, and finally return to your shell.