Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Docker rmi Command

Docker rmi Command

Docker Command ReferenceDocker Command Reference


docker rmi The command is used to delete one or more Docker images.

docker rmi The command is very useful for managing locally stored images, helping users clean up images they no longer need and free up storage space.

Syntax

docker rmi [OPTIONS] IMAGE [IMAGE...]

Parameter Description:

Common options:

Delete a single image



docker rmi ubuntu:latest

Delete the image named ubuntu with the latest tag.

** Delete multiple images**



docker rmi ubuntu:latest nginx:latest

Delete the images named ubuntu and nginx with the latest tag.

Delete multiple tags of an image



docker rmi ubuntu:latest ubuntu:18.04

Delete the latest and 18.04 tags of the ubuntu image.

** Delete all tags of an image**



docker rmi -a ubuntu

Delete all images under the ubuntu repository.

** Force delete images**



docker rmi -f ubuntu:latest

Force delete the ubuntu image with the latest tag, even if it is in use.

** Delete dangling images**



docker rmi -d

Delete all dangling images without tags.

** Quietly delete all images**



docker rmi -q $(docker images -q)

Use quiet mode to delete all images without showing information about the deleted images.

** Delete all images in a specified repository**



docker rmi -a myrepo

Delete all images under the myrepo repository.

** Delete an image and keep its child images**



docker rmi --no-prune ubuntu:latest

Delete the ubuntu:latest image but keep its child images.

Example

View existing images:



docker images

Output:



REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE

my_image            latest              d1e1b5a3a8a9        3 days ago          128MB

my_image1           latest              c3a4f5a3a8b8        4 days ago          256MB

my_image2           latest              a9e1d3a7c9b9        5 days ago          512MB

Delete an image:



docker rmi my_image

Output:



Untagged: my_image:latest

Deleted: sha256:d1e1b5a3a8a9...

Delete multiple images:



docker rmi my_image1 my_image2

Output:



Untagged: my_image1:latest

Deleted: sha256:c3a4f5a3a8b8...

Untagged: my_image2:latest

Deleted: sha256:a9e1d3a7c9b9...

Common Scenarios

Notes

docker rmi The command is a very important tool in Docker image management. With it, users can delete images they no longer need, free up storage space, and keep the local image library tidy. Using the appropriate options, the image deletion process can be managed flexibly.


Docker Command ReferenceDocker Command Reference