Challenge - 5 Problems
Container Cleanup Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
Output of removing a running container
What will be the output or result of running this command if the container
myapp is currently running?docker rm myappDocker
docker rm myapp
Attempts:
2 left
💡 Hint
Think about whether Docker allows removing containers that are running without extra flags.
✗ Incorrect
Docker does not allow removing a running container with 'docker rm' unless you use the '-f' (force) option. Without it, you get an error telling you to stop the container first.
💻 Command Output
intermediate1:30remaining
Effect of force removing a container
What happens when you run this command?
docker rm -f myappDocker
docker rm -f myapp
Attempts:
2 left
💡 Hint
The '-f' flag forces removal even if the container is running.
✗ Incorrect
The '-f' or '--force' option stops the container if it is running and then removes it.
❓ Configuration
advanced2:00remaining
Removing all stopped containers
Which command will remove all stopped containers safely without affecting running ones?
Attempts:
2 left
💡 Hint
Look for a command that cleans up stopped containers only.
✗ Incorrect
The command 'docker container prune' removes all stopped containers safely. Option D tries to remove all containers including running ones, causing errors. Option D forcibly removes running containers which is unsafe. Option D is invalid syntax.
❓ Troubleshoot
advanced1:30remaining
Error when removing container by name
You run
What is the most likely cause?
docker rm myapp but get the error:Error: No such container: myappWhat is the most likely cause?
Attempts:
2 left
💡 Hint
Check if the container name is correct and exists.
✗ Incorrect
The error means Docker cannot find a container with the name 'myapp'. It may have been removed or the name is misspelled.
✅ Best Practice
expert3:00remaining
Safe workflow to remove containers and free disk space
Which sequence of commands is the safest and most effective to remove all stopped containers and free disk space without affecting running containers or images?
Attempts:
2 left
💡 Hint
Start by removing stopped containers, then images, volumes, and networks.
✗ Incorrect
The best practice is to first remove stopped containers, then unused images, volumes, and networks in that order to safely free space without affecting running containers.