- First, list all the Docker images on your system to find the image you want to delete. Run the following command:
docker images
- Locate the image you want to delete in the list. Take note of the IMAGE ID or the REPOSITORY:TAG for thatĀ image.
- To delete the image, run the following command using either the IMAGE ID or the REPOSITORY:TAG:
Using IMAGE ID
:
docker rmi <IMAGE_ID>
Using REPOSITORY:TAG
:
docker rmi <REPOSITORY:TAG>
Replace <IMAGE_ID>
or <REPOSITORY:TAG>
with the appropriate value for the image you want to delete.
- The command should return a message indicating that the image has been deleted successfully. You can run
docker images
again to confirm that the image is no longer listed.
Important: Before deleting an image, make sure no containers are using it. If a container is using the image, you will need to stop and remove the container first