In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to delete image in Docker, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
The command to delete images in docker is docker rmi, but sometimes executing this command does not delete images
[yaxin@ubox ~] $docker imagesREPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZEeg_sshd latest ed9c93747fe1 45 hours ago 329.8 MBCentOS65 latest e55a74a32125 2 days ago 360.6 MB [yaxin@ubox ~] $docker rmi ed9c93747fe1Untagged: ed9c93747fe16627be822ad3f7feeb8b4468200e5357877d3046aa83cc44c6af [yaxin@ubox ~] $docker imagesREPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE ed9c93747fe1 45 hours ago 329.8 MBCentOS65 latest e55a74a32125 2 days ago 360.6 MB
As you can see, image has not been deleted, but his tag has been deleted. Executing docker rmi IMAGE_ID again will only report an error.
[yaxin@ubox ~] $docker rmi ed9c93747fe1Error: image_delete: Conflict, ed9c93747fe1 wasn't deleted2014/03/22 15:58:27 Error: failed to remove one or more images
If you look at docker's help, you will find that there are two delete-related commands, rm and rmi
Rm Remove one or more containersrmi Remove one or more images
There are two different words, images and container. Images is easy to understand, which means the same as the image of a virtual machine, which is equivalent to a template, and container is the state of the images runtime. Docker keeps a container for all running image, and you can use the command docker ps to view running container and docker ps-a for container that has exited. If you quit a container and forgot to save the data in it, you can use docker ps-a to find the corresponding running container and use the docker commit command to save it as image and run it.
Going back to the previous problem, because the image is referenced by a container (used to run), if the referenced container is not destroyed (deleted), then the image must not be deleted.
So if you want to delete a running images, you must first delete its container. Let's move on to the example just now.
[yaxin@ubox] $docker ps-aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES117843ade696 ed9c93747fe1 / bin/sh-c / usr/sbin 46 hours ago Up 46 hours 0.0.0.0 aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES117843ade696 ed9c93747fe1 49153-> 22/tcp test_sshd
You can see that ed9c93747fe1's image is used by 117843ade696's container, so you must first delete the container
[yaxin@ubox ~] $docker rm 117843ade696Error: container_delete: Impossible to remove a running container, please stop it first2014/03/22 16:36:44 Error: failed to remove one or more containers
An error occurred because the container is running (run docker ps to view), close it first
[yaxin@ubox ~] $docker stop 117843ade696117843ade696 [yaxin@ubox ~] $docker rm 117843ade696117843ade696 [yaxin@ubox ~] $docker rmi ed9c93747fe1Deleted: ed9c93747fe16627be822ad3f7feeb8b4468200e5357877d3046aa83cc44c6afDeleted: c8a0c19429daf73074040a14e527ad5734e70363c644f18c6815388b63eedc9bDeleted: 95dba4c468f0e53e5f1e5d76b8581d6740aab9f59141f783f8e263ccd7cf2a8eDeleted: c25dc743e40af6858c34375d450851bd606a70ace5d04e231a7fcc6d2ea23cc1Deleted: 20562f5714a5ce764845119399ef75e652e23135cd5c54265ff8218b61ccbd33Deleted: c8af1dc23af7a7aea0c25ba9b28bdee68caa8866f056e4f2aa2a5fa1bcb12693Deleted: 38fdb2c5432e08ec6121f8dbb17e1fde17d5db4c1f149a9b702785dbf7b0f3beDeleted: 79ca14274c80ac1df1333b89b2a41c0e0e3b91cd1b267b31bef852ceab3b2044 [yaxin@ubox ~] $docker imagesREPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZECentOS65 latest e55a74a32125 2 days ago 360.6 MB
As you can see, image has been deleted.
Thank you for reading this article carefully. I hope the article "how to delete image from Docker" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.