docker rm

Remove one or more stopped containers. Cannot remove running containers unless -f is used.

Syntax

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

Examples

Example 1
docker rm my-container

Remove a stopped container.

Example 2
docker rm -f my-container

Force remove a running container.

Example 3
docker rm $(docker ps -aq)

Remove all stopped containers.

Common flags

FlagDescription
-f, --forceForce remove running container
-v, --volumesRemove associated volumes

Tips & best practices

Related commands

View full Docker cheatsheet →