Recommended Free Tools
iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Remove one stopped container with docker rm <container>. To remove a running container cleanly, stop it first with docker stop <container>, then remove it. Use docker container prune to remove all stopped containers, or Docker Compose’s removal command for service containers. These commands have different effects on running processes and stored data, so choose by scope and check whether the container uses volumes before removing it.
Remove one stopped Docker container
Run docker rm followed by the container’s name or ID:
docker rm my-container
The command removes the specified container; Docker also accepts multiple names or IDs in one command. The equivalent long form is docker container rm. Docker documents the command as one that removes one or more containers: Docker container rm reference.
Stop a running container before removing it
For an orderly shutdown, stop the container and then remove it:
#1 Best Overall
docker stop my-container
docker rm my-container
Docker sends the container’s configured stop signal—SIGTERM by default—and then sends SIGKILL if its main process has not exited by the end of the grace period. When no timeout is configured, the documented default is 10 seconds for Linux containers and 30 seconds for Windows containers; configuration and platform affect the behavior. See the Docker container stop reference.
Force-remove a running container
If you need immediate removal rather than a graceful stop, use:
docker rm -f my-container
Force removal sends SIGKILL to the container’s main process. Because this does not allow the process to shut down gracefully, use it only when that interruption is acceptable.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsRank #2
Remove all stopped containers
To remove every stopped container, run:
docker container prune
Docker asks for confirmation by default. To skip the prompt, add --force:
docker container prune --force
Use a filter when you want to limit which stopped containers qualify. For example, this command targets stopped containers older than 24 hours:
docker container prune --filter "until=24h"
Prune supports filters including until and labels. Check the filter carefully before confirming; the command removes every stopped container that matches it. See the Docker container prune reference.
Rank #3
Remove containers managed by Docker Compose
From the Compose project directory, remove stopped service containers with:
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchdocker compose rm
To stop service containers as part of removal, add -s. To also remove associated anonymous volumes, add -v:
docker compose rm -s -v
Compose removal preserves anonymous volumes unless -v is supplied. Data stored only in the container’s writable filesystem is lost when the container is removed. Named volumes are distinct from anonymous volumes; inspect the project’s volume configuration and the Docker Compose rm reference before deleting data you need.
Understand what happens to container data and volumes
Removing a container is not the same as deleting every volume associated with it. With the ordinary docker rm command, associated volumes are not removed. Add -v to remove anonymous volumes associated with the container:
docker rm -v my-container
This does not remove named volumes. Docker also cannot remove a volume that is still in use. Data that exists only in the container’s writable filesystem disappears when the container is removed, so preserve it in a volume or copy it elsewhere if it must survive.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →For a one-off container you want Docker to clean up automatically on exit, start it with --rm:
Best Value
- Docker, Docker Swarm, Docker Compose, Programmer, Developer, Coding, Programming, Software Engineer, Code, DevOps, Deploy, Deployment, Kubernetes, Salt, Puppet, Chef, Terraform, Container, AWS, Azure, Cloud, Geek, Funny, Computer, Software, Tech, IT
- Integration, Scrum, Compile, Compilation, Science, Bug, Debug, Python, Linux, Java, Javascript, Scala, Dotnet, Kotlin
- Lightweight, Classic fit, Double-needle sleeve and bottom hem
docker run --rm ...
This automatically removes the container and its associated anonymous volumes after it exits; named volumes are retained. See the Docker container run reference.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Choose the right cleanup command
| Command | Scope | Process handling | Data considerations |
|---|---|---|---|
docker rm <container> |
One or more specified containers | Use for stopped containers; stop a running container first for graceful shutdown. | Does not remove associated volumes by default. |
docker stop <container>, then docker rm <container> |
One specified running container | Requests shutdown, then sends SIGKILL if the process exceeds the grace period. | Removing the container loses data stored only in its writable filesystem. |
docker rm -f <container> |
One specified running container | Force-removes it using SIGKILL. | Does not remove associated volumes by default. |
docker container prune |
All stopped containers, optionally limited by filters | Does not target running containers. | Removes containers, not their associated volumes by default. |
docker compose rm |
Stopped containers for Compose services | Add -s to stop them if needed. |
Add -v to remove associated anonymous volumes; container-filesystem data is lost. |
Do not use system prune for container-only cleanup
docker system prune has a wider scope than container removal: it can remove unused containers, networks, images, and build cache. Volumes are excluded by default; adding --volumes includes anonymous-volume pruning. Use it only when you intend to clean up those other unused resources as well. See the Docker system prune reference.

