Remove a Docker container
Updated August 29, 2026
Remove a stopped container with:
docker rm container-name
List containers first so you do not remove the wrong object:
docker ps -a
A running container must be stopped first, or you can explicitly force removal with docker rm --force after confirming the name/ID. Force removal sends a termination signal and can interrupt work. Removing a container does not remove the image it came from or named volumes attached to it.
To remove a Compose project's containers, run the command from its project directory and review what docker compose down will stop. Add volume removal only when the data is disposable. docker system prune is broader and can delete unused objects, so inspect its prompt and avoid using it as routine maintenance. If you need a clean application redeploy, preserve the data volume and configuration intentionally.
Sources
related.
Ruslan Osipov
About the author