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

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

docker rm [OPTIONS] CONTAINER [CONTAINER...]

Parameters

ParameterDescription
-f Force removal of a running container (sends SIGKILL).
-v Also remove anonymous volumes attached to the container.

Examples

Remove a stopped container
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.

Running containers need -f
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.

Was this page helpful?