博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
阿里云部署Docker(6)----解决删除<none>镜像问题
阅读量:5364 次
发布时间:2019-06-15

本文共 9997 字,大约阅读时间需要 33 分钟。

转载请注明来源,本博客原创作者为:

在Docker使用中,常常会碰到删除镜像不成功。反而让镜像变成了<none > <none>即,没名字,没Tag的镜像。

root@iZ28ikebrg6Z:/var/run# docker imagesREPOSITORY             TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
def2e0b08cbc About an hour ago 1.37 GBsameersbn/redmine latest f0bec095f291 2 hours ago 614.6 MBsameersbn/gitlab latest bf5c375d9057 3 days ago 635.1 MB
9cbaf023786c 3 days ago 192.8 MBsameersbn/postgresql latest 24a6064fa4cd 10 days ago 142.1 MB
48648094d099 5 weeks ago 997.9 MB
195fa62e92a8 6 weeks ago 496.4 MBtraining/webapp latest 31fa814ba25a 4 months ago 278.8 MBsameersbn/redmine 2.4.2 b95b8046d47c 8 months ago 1.327 GB
好多<none>。删又删不了。

这主要是一些container使用了该image导致的,不不过说如今执行的容器,之前执行的也会。

docker ps -a
能够查历史记录,然后将container commit成镜像。

我们须要删除这些依赖Image的container,当使用到该镜像的全部container都删除了。就能够直接用IMAGE_ID来删除该镜像。

root@iZ28ikebrg6Z:/var/run# docker ps -aCONTAINER ID        IMAGE                    COMMAND                CREATED             STATUS                     PORTS               NAMES5d6373cb79e6        224b40d4b89f             "/bin/sh -c 'apt-get   25 hours ago        Exited (0) 25 hours ago                        distracted_blackwell     aa47ba8e71c8        training/webapp:latest   "python app.py"        28 hours ago        Exited (-1) 27 hours ago                       suspicious_ardinghelli   09792841c0b4        training/webapp:latest   "python app.py"        29 hours ago        Exited (-1) 27 hours ago                       compassionate_torvalds   d8eca9742031        9cbaf023786c             "/bin/sh -c 'while t   31 hours ago        Exited (-1) 30 hours ago                       mad_jones                95d20e5442f9        9cbaf023786c             "/bin/bash"            31 hours ago        Exited (0) 31 hours ago                        stupefied_torvalds       9d40292642e6        9cbaf023786c             "/bin/echo 'hello wo   31 hours ago        Exited (0) 31 hours ago                        stoic_mclean             1078d5bd868e        9cbaf023786c             "/bin/echo 'hello wo   31 hours ago        Exited (0) 31 hours ago                        high_leakey              e88cad8893f5        9cbaf023786c             "/bin/echo hello"      31 hours ago        Exited (0) 31 hours ago                        compassionate_mclean     0949d7b6148d        9cbaf023786c             "/bin/echo 'hello wo   31 hours ago        Exited (0) 31 hours ago                        romantic_carson          e5ab0f35322f        9cbaf023786c             "/bin/bash"            31 hours ago        Exited (0) 31 hours ago                        romantic_elion           9fbad8b573d3        9cbaf023786c             "/bin/bash"            32 hours ago        Exited (0) 31 hours ago                        thirsty_davinci          9ce1789ee43d        9cbaf023786c             "/bin/echo hello"      32 hours ago        Exited (0) 32 hours ago                        insane_colden
一个个的删除

root@iZ28ikebrg6Z:/var/run# docker rm 5d635d63root@iZ28ikebrg6Z:/var/run# docker rm  aa47aa47root@iZ28ikebrg6Z:/var/run# docker rm  09790979root@iZ28ikebrg6Z:/var/run# docker rm  d8ecd8ecroot@iZ28ikebrg6Z:/var/run# docker rm  95d95droot@iZ28ikebrg6Z:/var/run# docker rm  9d49d4root@iZ28ikebrg6Z:/var/run# docker rm  10781078root@iZ28ikebrg6Z:/var/run# docker rm  e88ce88croot@iZ28ikebrg6Z:/var/run# docker rm  09490949root@iZ28ikebrg6Z:/var/run# docker rm  e5abe5abroot@iZ28ikebrg6Z:/var/run# docker rm  9fba9fbaroot@iZ28ikebrg6Z:/var/run# docker rm  9ce19ce1root@iZ28ikebrg6Z:/var/run# docker ps -aCONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
root@iZ28ikebrg6Z:/var/run# docker imagesREPOSITORY             TAG                 IMAGE ID            CREATED             VIRTUAL SIZEsameersbn/redmine      latest              f0bec095f291        3 hours ago         614.6 MBsameersbn/gitlab       latest              bf5c375d9057        3 days ago          635.1 MBsameersbn/postgresql   latest              24a6064fa4cd        10 days ago         142.1 MB
48648094d099 5 weeks ago 997.9 MB
195fa62e92a8 6 weeks ago 496.4 MBtraining/webapp latest 31fa814ba25a 4 months ago 278.8 MBsameersbn/redmine 2.4.2 b95b8046d47c 8 months ago 1.327 GBroot@iZ28ikebrg6Z:/var/run# docker rmi 4864Deleted: 48648094d099bf7c38c5687f4cde3f2b7d27e8a1dc45c30d8fdf8e5f42c2473eDeleted: 4b1b0cd0c62c3e86701bf4bc4736ca403e3ddd264101d69110bd1924bf05ec2dDeleted: cd2308a31b296d77f1ef1562432d3908582528ed13d838a3ab6702e7d19ce604Deleted: 212c2526444a6cefedf9d985f2727bef4b50b84062400a8f1d98b19f779baf3dDeleted: ac89032e1c4548eaf6f6bf817850431b9180a5b7f06b29e6d7f73b4b8878fe10Deleted: dcd2c451d11f4896c31b0178c41bf764a87625004ff0048863e627474147c413Deleted: 7eac533353c28beeab8fd4abb5a6663abc99f0cf24d3650963352f3a41ce8e29Deleted: 11ed21fa7166f4dee1cfe406885d889f07222a458e706c9d30c28aa9e4cfc398Deleted: cf6daa523a25b1b947138ad883d18f8501d210ae110487066a9b4ccd8fbd9c70Deleted: 830bf73bda66fe5ac8bf9262b5be7f4cfacec7a2dd28b7d8cb61c505e68fb787Deleted: 41176d2b465f4072fa46897aef5f4e35a1941d73a20687bb704c2bfd789a5ae3Deleted: fa078497ab6f0be3ce013f336ff052af7eaa96cbe2e14e3e6f6352c00544ede0Deleted: 4477fcbe8e773d2699bf50a6a24b265fbede90ab95793e9cd36f1627348424edDeleted: 314c98eff22790bf333b9f98ff39576d9cfbeb3f380fe839ca74ef641b30d1f6Deleted: 01fb8a54ae0821edb5d6d30280b56c47934efa05b158b67ad3a4a4bb9a82928bDeleted: 533b41917c87f1479dd6cc852cf8ad11ccd9ef93d5b42978b66bbb1bb30dd476Deleted: b9c0b9efe68d7fe7caa1c9dcfd61a0aa4a3fb4e2629b7d10c9140a495a438855Deleted: a91d7692121d15b5399bfb0b4096aa7d696d9e0e0b44269479e5666ea3b39dd9Deleted: 37d36b47338de2dca6f957a520016d9e7ca4db1e57d6eb38824c9ba267b29db7Deleted: c4ff7513909dedf4ddf3a450aea68cd817c42e698ebccf54755973576525c416Deleted: cc58e55aa5a53b572f3b9009eb07e50989553b95a1545a27dcec830939892dbaDeleted: 0ea0d582fd9027540c1f50c7f0149b237ed483d2b95ac8d107f9db5a912b4240Deleted: d92c3c92fa73ba974eb409217bb86d8317b0727f42b73ef5a05153b729aaf96bDeleted: 9942dd43ff211ba917d03637006a83934e847c003bef900e4808be8021dca7bdDeleted: 1c9383292a8ff4c4196ff4ffa36e5ff24cb217606a8d1f471f4ad27c4690e290root@iZ28ikebrg6Z:/var/run# docker imagesREPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZEsameersbn/redmine latest f0bec095f291 3 hours ago 614.6 MBsameersbn/gitlab latest bf5c375d9057 3 days ago 635.1 MBsameersbn/postgresql latest 24a6064fa4cd 10 days ago 142.1 MB
195fa62e92a8 6 weeks ago 496.4 MBtraining/webapp latest 31fa814ba25a 4 months ago 278.8 MBsameersbn/redmine 2.4.2 b95b8046d47c 8 months ago 1.327 GBroot@iZ28ikebrg6Z:/var/run# docker rmi 195fError response from daemon: No such image: 762df2d4d7bb52a46148cf3e5ab423b30aafd58ca8f758ea78ea2cbd1b1753b62014/10/17 17:26:04 Error: failed to remove one or more imagesroot@iZ28ikebrg6Z:/var/run# docker imagesREPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZEsameersbn/redmine latest f0bec095f291 3 hours ago 614.6 MBsameersbn/gitlab latest bf5c375d9057 3 days ago 635.1 MBsameersbn/postgresql latest 24a6064fa4cd 10 days ago 142.1 MBtraining/webapp latest 31fa814ba25a 4 months ago 278.8 MBsameersbn/redmine 2.4.2 b95b8046d47c 8 months ago 1.327 GBroot@iZ28ikebrg6Z:/var/run#
好,删除干净了。

还我们一个干净的工作区间。

docker的删除有两种。一个是rm 删除容器,一个是rmi删除镜像。

rm Remove one or more containers

rmi Remove one or more images

这里有两个不同的单词,images和container。当中images非常好理解。跟寻常使用的虚拟机的镜像一个意思,相当于一个模版,而container则是images执行时的的状态。

docker对于执行过的image都保留一个状态(container)。能够使用命令docker ps来查看正在执行的container。对于已经退出的container。则能够使用docker ps -a来查看。

假设你退出了一个container而忘记保存当中的数据。你能够使用docker ps -a来找到相应的执行过的container使用docker commit命令将其保存为image然后执行。

回到之前的问题。因为image被某个container引用(拿来执行),假设不将这个引用的container销毁(删除),那image肯定是不能被删除。

所以想要删除执行过的images必须首先删除它的container。继续来看刚才的样例,

[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:49153->22/tcp   test_sshd

能够看出ed9c93747fe1的image被117843ade696的container使用着。所以必须首先删除该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

出现错误,这是由于该container正在执行中(执行docker ps查看),先将其关闭

[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

能够看出,image已经被删除

转载于:https://www.cnblogs.com/zsychanpin/p/6768070.html

你可能感兴趣的文章
《Linux内核设计与实现》第四章学习笔记
查看>>
Docker 安装MySQL5.7(三)
查看>>
CF1067C Knights 构造
查看>>
CSS: caption-side 属性
查看>>
CSS3中box-sizing的理解
查看>>
Web.Config文件配置之配置Session变量的生命周期
查看>>
mysql导入source注意点
查看>>
linux下编译安装nginx
查看>>
DLL 导出函数
查看>>
windows超过最大连接数解决命令
查看>>
12个大调都是什么
查看>>
angular、jquery、vue 的区别与联系
查看>>
Intellij idea创建javaWeb以及Servlet简单实现
查看>>
代理网站
查看>>
Open multiple excel files in WebBrowser, only the last one gets activated
查看>>
FFmpeg进行视频帧提取&音频重采样-Process.waitFor()引发的阻塞超时
查看>>
最近邻与K近邻算法思想
查看>>
【VS开发】ATL辅助COM组件开发
查看>>
FlatBuffers In Android
查看>>
《演说之禅》I &amp; II 读书笔记
查看>>