docker rmi
command is used to remove one or more images from the host machine. If an image has multiple tags, then running this command with the tag only removes the tag. But if an image has only one tag, then both image and tag will be removed.
$ docker rmi [OPTIONS] IMAGE [IMAGE...]
--force
, -f
→ Force removal of the Image--no-prune
→ Do not delete untagged ones$ docker images
ubuntu latest d2e4e1f51132 5 minutes ago 77.8MB
php 7.4 b9e8bd54d0cd 12 days ago 473MB
node 18-alpine3.15 ecf4574a690a 2 weeks ago 174MB
nginxinc/nginx-unprivileged 1-alpine de38122b9c8a 2 months ago 23.4MB
postgres latest 74b0c105737a 2 months ago 376MB
$ docker rmi d2e4e1f51132
Deleted: d2e4e1f51132e234d2d2e4e1f51132d2e4e1f51132d2e4e1f5fse3
$ docker images
php 7.4 b9e8bd54d0cd 12 days ago 473MB
node 18-alpine3.15 ecf4574a690a 2 weeks ago 174MB
nginxinc/nginx-unprivileged 1-alpine de38122b9c8a 2 months ago 23.4MB
postgres latest 74b0c105737a 2 months ago 376MB
Also using the tag:
$ docker rmi php:7.4
Untagged: php:7.4
Deleted: b9e8bd54d0cd2ed232ws32b9e8bd54d0cdb9e8bd54d0cdb9e8bd54d0cd