images
docker rmi
Removes one or more images from the local image store. Alias for docker image rm.
docker rmi [OPTIONS] IMAGE [IMAGE...] Common flags
| Flag | Purpose |
|---|---|
| -f, --force | Force removal even if the image is tagged in multiple repositories |
| --no-prune | Do not delete untagged parent images |
Examples
docker rmi nginx:1.27-alpine Remove a specific tagged image
docker rmi -f $(docker images -q) Force-remove every image
docker image prune -a Prune all images not used by any container
docker rmi $(docker images -f dangling=true -q) Delete only dangling <none> layers
Gotcha
You cannot remove an image while any container (even stopped) references it — remove the container first, or use -f. -f only untags on multi-tag images; the underlying layers may remain until fully unreferenced.
Related commands
docker images
Lists images stored in the local image store with their repository, tag, ID, and size. Alias for docker image ls.
docker rm
Removes one or more stopped containers from the host. Use -f to force-remove a running container.
docker pull
Downloads an image or repository from a registry into the local image store. Defaults to Docker Hub and the latest tag when unspecified.
docker build
Builds an image from a Dockerfile and a build context. In Docker 23+ this invokes BuildKit by default and supports multi-platform, secrets, and cache mounts.
docker tag
Creates a new tag (alias) that refers to an existing image. Tagging is required before pushing to a registry whose hostname is not Docker Hub.
← All Docker commands · Docker vs Kubernetes · Docker vs VMs