Docker Engine 29 reference · Containers
docker rm Command (Docker CLI)
Remove one or more stopped containers and their writable layers; -f stops and removes running ones too.
Docker Engine 29
Syntax
docker rm [OPTIONS] CONTAINER [CONTAINER...]
Parameters
| Parameter | Description |
|---|---|
-f |
Force removal of a running container (sends SIGKILL). |
-v |
Also remove anonymous volumes attached to the container. |
Examples
docker run --name rc-ref-rm alpine:3.24 true
docker rm rc-ref-rm
docker ps -a --filter name=rc-ref-rm --format '{{.Names}}' | wc -l
Output
rc-ref-rm 0
Run this on your computer — see “Get Started” for setup.
docker run -d --name rc-ref-rm2 alpine:3.24 sleep 300 > /dev/null
docker rm rc-ref-rm2 > /dev/null 2>&1 || echo 'docker rm refused: the container is running'
docker rm -f rc-ref-rm2
Output
docker rm refused: the container is running rc-ref-rm2
Run this on your computer — see “Get Started” for setup.
Removing a container deletes its writable layer: anything not in a volume is gone.
Related
docker stop· Stop running containers gracefully: send SIGTERM, wait for the timeout (10 s by default), then SIGKILL.docker ps· List containers: running ones by default, all with -a, filtered and formatted for scripts with --filter and --format.- The Container Lifecycle · tutorial