Docker : How to delete a Docker image

 

  1. First, list all the Docker images on your system to find the image you want to delete. Run the following command:
docker images
  1. Locate the image you want to delete in the list. Take note of the IMAGE ID or the REPOSITORY:TAG for thatĀ image.
  2. 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.

  1. 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

Author: user

Leave a Reply