Docker container Image Removal

Source: Internet
Author: User
Tags docker ps

Well, I thought it would be easy to remove the image, but it's a little bit of a puzzle to start with. By deleting it, it was easy to find out. Share My experience:

In two cases: to remove the image, first delete the container, delete the container, make sure the container is stopped, 2; the command to delete the container and delete the mirror is slightly different: Delete container (rm), delete image (RMI). The whole process is as follows:

1 Querying the current image (Docker image):

As you can see, the current image has Nginx and Tomcat. I want to remove the Tomcat image whose image ID is: 41a54fe1f79d

2 Query Container (Docker ps-a)

As you can see, the ID of the container is: f2bb0c0216d6

3 If you now delete the image directly, see what happens:

(1) The container does not stop running:

At this point, Tip:conflict:unable to delete 41a54fe1f79d (cannot be forced)-image is being used by running container f2bb0c0216 d6; Cannot delete

(2) The container stops running:

At this point, Tip:conflict:unable to delete 41a54fe1f79d (must be forced)-image is being used by stopped container F2BB0C0216D6

4 Therefore, you can delete the mirror only if you delete the container first:

Docker container Image Removal

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.