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