docker-rm
Remove Docker containers
TLDR
View documentation for the original command
SYNOPSIS
docker rm [OPTIONS] CONTAINER [CONTAINER...]
PARAMETERS
-f, --force
Force removal of running containers by sending SIGKILL signal and ignoring errors.
-v, --volumes
Remove anonymous volumes associated with the container (named volumes unaffected).
DESCRIPTION
The docker rm command is used to delete one or more stopped Docker containers from the host machine. Containers represent isolated environments for running applications, and removing them frees up resources like disk space and port bindings. By default, docker rm only works on stopped containers; attempting to remove a running one results in an error. Use the -f or --force option to forcefully stop and remove running containers via SIGKILL signal.
This command does not affect container images, volumes (unless specified), or networks unless explicitly handled. It's essential for cleanup after testing or development workflows. For example, combine with docker ps -aq to remove all containers: docker rm $(docker ps -aq). Always verify container IDs or names before removal to avoid accidental deletions.
Anonymous volumes are preserved by default to prevent data loss, but named volumes require separate docker volume rm. This makes docker rm a core tool in Docker lifecycle management, promoting efficient resource utilization in containerized environments.
CAVEATS
Running containers require -f; linked containers block removal until dependencies resolved; does not prune unused images or named volumes automatically.
EXAMPLES
docker rm my-container # Remove stopped container
docker rm -f my-container # Force remove running
docker rm -v $(docker ps -aq) # Remove all with anon volumes
EXIT CODES
0: Success
1: Failure (e.g., container running without -f)
HISTORY
Introduced in Docker 1.0 (2014) as part of core CLI; enhanced in later versions with volume handling (-v added ~1.9) to improve data safety.
SEE ALSO
docker-stop(1), docker-kill(1), docker-rmi(1), docker-volume-rm(1)


