Docker
/Beginner
docker rm
Definition
The CLI command used to permanently delete one or more containers from the host system, freeing up disk space.
Explain Like I'm New
Throwing the container in the trash. Once you do this, the container and all the un-saved data inside it are gone forever.
Real World Example
You ran a temporary Ubuntu container just to test a bash script. You're done with it. You type `docker rm test-ubuntu` so it doesn't clutter up your hard drive.
Common Use Cases
- •Cleaning up environments
- •Resetting state
Crucial Command Flags
| Flag / Option | Description |
|---|---|
| -f / --force | Force the removal of a running container (uses SIGKILL). |
| -v / --volumes | Remove anonymous volumes associated with the container. |
Interview Questions
basic
- Can you run `docker rm` on a container that is currently running?
intermediate
- What does the flag `--rm` do when attached to the `docker run` command?