LinuxCommandLibrary

docker-container-rm

remove one or more containers

TLDR

Remove a container

$ docker container rm [container]
copy
Remove multiple containers
$ docker container rm [container1] [container2]
copy
Force remove running container
$ docker container rm -f [container]
copy
Remove container and volumes
$ docker container rm -v [container]
copy
Remove all stopped containers
$ docker container rm $(docker container ls -aq -f status=exited)
copy

SYNOPSIS

docker container rm [options] container [container...]

DESCRIPTION

docker container rm removes one or more containers from the Docker host, freeing disk space occupied by the container's read-write layer and metadata. Containers must be stopped before removal unless the -f flag is used to force removal of running containers.
The -v option also removes anonymous volumes associated with the container, which is useful for complete cleanup. Named volumes are preserved by default to prevent accidental data loss.

PARAMETERS

-f, --force

Force removal of running container.
-v, --volumes
Remove anonymous volumes.
-l, --link
Remove specified link.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community