Challenge - 5 Problems
Container Restart Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of restarting a stopped container?
You have a Docker container named
webapp that is currently stopped. You run the command docker restart webapp. What will be the output?Docker
docker restart webappAttempts:
2 left
💡 Hint
The restart command returns the container name if successful.
✗ Incorrect
The
docker restart command outputs the container name when it successfully restarts the container, even if it was stopped before.❓ Troubleshoot
intermediate2:00remaining
Why does
docker restart fail with 'No such container'?You run
docker restart mycontainer but get the error Error: No such container: mycontainer. What is the most likely cause?Docker
docker restart mycontainerAttempts:
2 left
💡 Hint
Check if the container name matches exactly.
✗ Incorrect
The error means Docker cannot find a container with the given name or ID. It usually means a typo or the container was removed.
❓ Configuration
advanced2:00remaining
How to configure automatic restart of a container on failure?
You want a container to restart automatically only if it crashes (exits with error). Which Docker run option achieves this?
Docker
docker run --restart=? myimageAttempts:
2 left
💡 Hint
This option restarts only on non-zero exit codes.
✗ Incorrect
The
--restart=on-failure option restarts the container only if it exits with a failure code, not on normal exit.🔀 Workflow
advanced2:00remaining
What is the correct sequence to restart all running containers?
You want to restart all currently running Docker containers with a single command sequence. Which option correctly does this?
Attempts:
2 left
💡 Hint
Use only running containers' IDs.
✗ Incorrect
The command
docker ps -q lists only running containers. Passing these IDs to docker restart restarts all running containers.✅ Best Practice
expert2:00remaining
What is the best practice to ensure a container restarts after Docker daemon reboot?
You want your container to restart automatically after the Docker service or host machine restarts. Which restart policy is best suited for this?
Attempts:
2 left
💡 Hint
This policy restarts containers except when explicitly stopped.
✗ Incorrect
The
--restart=always policy restarts containers after daemon or host reboot regardless of how the container was stopped.