The docker rmi
command is used to remove one or more Docker images from your system. It allows you to delete images that are no longer needed, freeing up disk space on your machine.
To use the docker rmi
command, you can follow these steps:
-
Make sure you have Docker installed and running on your system.
-
Open a terminal or command prompt.
-
To remove an image, you need to know the image’s ID or name. You can find the ID or name of the image by using the
docker images
command:docker images
This will display a list of available images along with their details.
-
Once you have the image ID or name, you can use the
docker rmi
command followed by the image ID or name:docker rmi {{image-id-or-name}}
Replace
{{image-id-or-name}}
with the actual ID or name of the image you want to remove.For example, to remove an image with the ID
1234567890ab
, you can use:docker rmi 1234567890ab
-
After running the
docker rmi
command, Docker will delete the specified image from your system. If the image is being used by any containers, Docker will display an error message and refuse to delete the image. In that case, you need to remove the associated containers first using thedocker rm
command. -
You can verify that the image has been removed by using the
docker images
command again. The image should no longer appear in the list of available images.
Please note that the docker rmi
command permanently deletes an image and its associated layers. Be cautious when using this command, as it cannot be undone. If you want to remove multiple images at once, you can specify multiple image IDs or names separated by spaces in the docker rmi
command.