0
0
Dockerdevops~20 mins

Starting and stopping containers in Docker - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Container Control Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of stopping a non-running container?
You run the command docker stop mycontainer but the container mycontainer is already stopped. What will Docker output?
ANothing, the command silently succeeds
BError: No such container: mycontainer
CContainer mycontainer is already stopped
Dmycontainer
Attempts:
2 left
💡 Hint
Docker stop returns the container name if it exists, even if already stopped.
💻 Command Output
intermediate
2:00remaining
What happens when you start a container that is already running?
You run docker start mycontainer but mycontainer is already running. What is the output?
Amycontainer
BError: Container already running
CNothing, command silently succeeds
DContainer mycontainer restarted
Attempts:
2 left
💡 Hint
Docker start returns the container name regardless of state if container exists.
Troubleshoot
advanced
3:00remaining
Why does docker stop hang on a container?
You run docker stop mycontainer but the command hangs and does not return. What is a likely cause?
ADocker daemon is not running
BThe container image is corrupted
CThe container's main process ignores SIGTERM and does not exit
DThe container is already stopped
Attempts:
2 left
💡 Hint
Stopping sends SIGTERM then SIGKILL after timeout if needed.
🔀 Workflow
advanced
3:00remaining
What is the correct sequence to restart a container safely?
You want to restart a container named webapp safely, ensuring it stops before starting again. Which sequence of commands is best?
Adocker restart webapp
Bdocker stop webapp && docker start webapp
Cdocker kill webapp && docker start webapp
Ddocker start webapp && docker stop webapp
Attempts:
2 left
💡 Hint
Restart command stops then starts but may not allow custom wait times.
Best Practice
expert
3:00remaining
Which command safely stops all running containers?
You want to stop all running Docker containers safely with one command. Which command achieves this?
Adocker stop $(docker ps -q)
Bdocker kill $(docker ps -q)
Cdocker rm $(docker ps -q)
Ddocker pause $(docker ps -q)
Attempts:
2 left
💡 Hint
Stopping sends SIGTERM to allow graceful shutdown.