阿里云部署Docker(6)----解决删除<none>镜像问题

原创 2014年10月17日 17:31:35

转载请注明来源,本博客原创作者为:http://blog.csdn.net/minimicall?viewmode=contents

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

root@iZ28ikebrg6Z:/var/run# docker images
REPOSITORY             TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
<none>                 <none>              def2e0b08cbc        About an hour ago   1.37 GB
sameersbn/redmine      latest              f0bec095f291        2 hours ago         614.6 MB
sameersbn/gitlab       latest              bf5c375d9057        3 days ago          635.1 MB
<none>                 <none>              9cbaf023786c        3 days ago          192.8 MB
sameersbn/postgresql   latest              24a6064fa4cd        10 days ago         142.1 MB
<none>                 <none>              48648094d099        5 weeks ago         997.9 MB
<none>                 <none>              195fa62e92a8        6 weeks ago         496.4 MB
training/webapp        latest              31fa814ba25a        4 months ago        278.8 MB
sameersbn/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 -a
CONTAINER ID        IMAGE                    COMMAND                CREATED             STATUS                     PORTS               NAMES
5d6373cb79e6        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 5d63
5d63
root@iZ28ikebrg6Z:/var/run# docker rm  aa47
aa47
root@iZ28ikebrg6Z:/var/run# docker rm  0979
0979
root@iZ28ikebrg6Z:/var/run# docker rm  d8ec
d8ec
root@iZ28ikebrg6Z:/var/run# docker rm  95d
95d
root@iZ28ikebrg6Z:/var/run# docker rm  9d4
9d4
root@iZ28ikebrg6Z:/var/run# docker rm  1078
1078
root@iZ28ikebrg6Z:/var/run# docker rm  e88c
e88c
root@iZ28ikebrg6Z:/var/run# docker rm  0949
0949
root@iZ28ikebrg6Z:/var/run# docker rm  e5ab
e5ab
root@iZ28ikebrg6Z:/var/run# docker rm  9fba
9fba
root@iZ28ikebrg6Z:/var/run# docker rm  9ce1
9ce1
root@iZ28ikebrg6Z:/var/run# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

root@iZ28ikebrg6Z:/var/run# docker images
REPOSITORY             TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
sameersbn/redmine      latest              f0bec095f291        3 hours ago         614.6 MB
sameersbn/gitlab       latest              bf5c375d9057        3 days ago          635.1 MB
sameersbn/postgresql   latest              24a6064fa4cd        10 days ago         142.1 MB
<none>                 <none>              48648094d099        5 weeks ago         997.9 MB
<none>                 <none>              195fa62e92a8        6 weeks ago         496.4 MB
training/webapp        latest              31fa814ba25a        4 months ago        278.8 MB
sameersbn/redmine      2.4.2               b95b8046d47c        8 months ago        1.327 GB
root@iZ28ikebrg6Z:/var/run# docker rmi 4864
Deleted: 48648094d099bf7c38c5687f4cde3f2b7d27e8a1dc45c30d8fdf8e5f42c2473e
Deleted: 4b1b0cd0c62c3e86701bf4bc4736ca403e3ddd264101d69110bd1924bf05ec2d
Deleted: cd2308a31b296d77f1ef1562432d3908582528ed13d838a3ab6702e7d19ce604
Deleted: 212c2526444a6cefedf9d985f2727bef4b50b84062400a8f1d98b19f779baf3d
Deleted: ac89032e1c4548eaf6f6bf817850431b9180a5b7f06b29e6d7f73b4b8878fe10
Deleted: dcd2c451d11f4896c31b0178c41bf764a87625004ff0048863e627474147c413
Deleted: 7eac533353c28beeab8fd4abb5a6663abc99f0cf24d3650963352f3a41ce8e29
Deleted: 11ed21fa7166f4dee1cfe406885d889f07222a458e706c9d30c28aa9e4cfc398
Deleted: cf6daa523a25b1b947138ad883d18f8501d210ae110487066a9b4ccd8fbd9c70
Deleted: 830bf73bda66fe5ac8bf9262b5be7f4cfacec7a2dd28b7d8cb61c505e68fb787
Deleted: 41176d2b465f4072fa46897aef5f4e35a1941d73a20687bb704c2bfd789a5ae3
Deleted: fa078497ab6f0be3ce013f336ff052af7eaa96cbe2e14e3e6f6352c00544ede0
Deleted: 4477fcbe8e773d2699bf50a6a24b265fbede90ab95793e9cd36f1627348424ed
Deleted: 314c98eff22790bf333b9f98ff39576d9cfbeb3f380fe839ca74ef641b30d1f6
Deleted: 01fb8a54ae0821edb5d6d30280b56c47934efa05b158b67ad3a4a4bb9a82928b
Deleted: 533b41917c87f1479dd6cc852cf8ad11ccd9ef93d5b42978b66bbb1bb30dd476
Deleted: b9c0b9efe68d7fe7caa1c9dcfd61a0aa4a3fb4e2629b7d10c9140a495a438855
Deleted: a91d7692121d15b5399bfb0b4096aa7d696d9e0e0b44269479e5666ea3b39dd9
Deleted: 37d36b47338de2dca6f957a520016d9e7ca4db1e57d6eb38824c9ba267b29db7
Deleted: c4ff7513909dedf4ddf3a450aea68cd817c42e698ebccf54755973576525c416
Deleted: cc58e55aa5a53b572f3b9009eb07e50989553b95a1545a27dcec830939892dba
Deleted: 0ea0d582fd9027540c1f50c7f0149b237ed483d2b95ac8d107f9db5a912b4240
Deleted: d92c3c92fa73ba974eb409217bb86d8317b0727f42b73ef5a05153b729aaf96b
Deleted: 9942dd43ff211ba917d03637006a83934e847c003bef900e4808be8021dca7bd
Deleted: 1c9383292a8ff4c4196ff4ffa36e5ff24cb217606a8d1f471f4ad27c4690e290
root@iZ28ikebrg6Z:/var/run# docker images
REPOSITORY             TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
sameersbn/redmine      latest              f0bec095f291        3 hours ago         614.6 MB
sameersbn/gitlab       latest              bf5c375d9057        3 days ago          635.1 MB
sameersbn/postgresql   latest              24a6064fa4cd        10 days ago         142.1 MB
<none>                 <none>              195fa62e92a8        6 weeks ago         496.4 MB
training/webapp        latest              31fa814ba25a        4 months ago        278.8 MB
sameersbn/redmine      2.4.2               b95b8046d47c        8 months ago        1.327 GB
root@iZ28ikebrg6Z:/var/run# docker rmi 195f
Error response from daemon: No such image: 762df2d4d7bb52a46148cf3e5ab423b30aafd58ca8f758ea78ea2cbd1b1753b6
2014/10/17 17:26:04 Error: failed to remove one or more images
root@iZ28ikebrg6Z:/var/run# docker images
REPOSITORY             TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
sameersbn/redmine      latest              f0bec095f291        3 hours ago         614.6 MB
sameersbn/gitlab       latest              bf5c375d9057        3 days ago          635.1 MB
sameersbn/postgresql   latest              24a6064fa4cd        10 days ago         142.1 MB
training/webapp        latest              31fa814ba25a        4 months ago        278.8 MB
sameersbn/redmine      2.4.2               b95b8046d47c        8 months ago        1.327 GB
root@iZ28ikebrg6Z:/var/run# 
好,删除干净了。还我们一个干净的工作区间。



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

rm Remove one or more containers
rmi Remove one or more images

这里有两个不同的单词,imagescontainer。其中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 -a
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS                   NAMES
117843ade696        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 117843ade696
Error: container_delete: Impossible to remove a running container, please stop it first
2014/03/22 16:36:44 Error: failed to remove one or more containers

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

[yaxin@ubox ~]$docker stop 117843ade696
117843ade696
[yaxin@ubox ~]$docker rm 117843ade696
117843ade696
[yaxin@ubox ~]$docker rmi ed9c93747fe1
Deleted: ed9c93747fe16627be822ad3f7feeb8b4468200e5357877d3046aa83cc44c6af
Deleted: c8a0c19429daf73074040a14e527ad5734e70363c644f18c6815388b63eedc9b
Deleted: 95dba4c468f0e53e5f1e5d76b8581d6740aab9f59141f783f8e263ccd7cf2a8e
Deleted: c25dc743e40af6858c34375d450851bd606a70ace5d04e231a7fcc6d2ea23cc1
Deleted: 20562f5714a5ce764845119399ef75e652e23135cd5c54265ff8218b61ccbd33
Deleted: c8af1dc23af7a7aea0c25ba9b28bdee68caa8866f056e4f2aa2a5fa1bcb12693
Deleted: 38fdb2c5432e08ec6121f8dbb17e1fde17d5db4c1f149a9b702785dbf7b0f3be
Deleted: 79ca14274c80ac1df1333b89b2a41c0e0e3b91cd1b267b31bef852ceab3b2044
[yaxin@ubox ~]$docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
CentOS65            latest              e55a74a32125        2 days ago          360.6 MB

可以看出,image已经被删除




版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

Docker 技巧:删除 Docker 容器和镜像

删除所有未运行 Docker 容器docker rm $(docker ps -a -q)删除所有 Docker 镜像删除所有未打 tag 的镜像docker rmi $(docker images ...

删除docker images中为none的镜像

由于平时一直使用docker build 命令才生成一个镜像,有时候由于代码跟新频繁就会产生很多的none的image,最近想着清除一下。 于是就写了以下脚本:docker ps -a | grep...

Docker中images中none的镜像是否可以删除

Docker中images中none的镜像是否可以删除呢? 担心删除了会有问题啊,小白用户啊。查查资料还是收获不少哦。简要翻译国外的一篇文章哈,不对请指正。 What are : ...

新手学习Docker之------如何上传下载镜像

前言 镜像是Docker最核心的技术之一,也是应用发布的标准格式。Docker 镜像源与Git中的repo地址有些相似。在Docker的默认配置中,其镜像源主要是来自官方Registry(官方网站专门...

如何更快的拉取国内的docker镜像

由于国内访问直接访问Docker hub网速比较慢,拉取镜像的时间就会比较长。一般我们会使用镜像加速或者直接从国内的一些平台镜像仓库上拉取。 使用比较多的是: daocloud镜像市场:http...

docker使用阿里云Docker镜像库加速(修订版)

本人专属加速器地址:https://pee6w651.mirror.aliyuncs.comubuntu安装或升级Docker请安装1.6.0以上版本的Docker。 您可以通过阿里云的镜像仓库下载...
  • bwlab
  • bwlab
  • 2016-01-19 14:23
  • 72229

解决docker镜像无法下载的问题

克服跨洋网络延迟,使用Docker Hub Mirror加速Docker官方镜像下载 http://cloud.51cto.com/art/201501/463536.htm 此篇文章给了我启示,...

docker国内镜像拉取和镜像加速registry-mirrors配置修改

拉取docker国内镜像,加速器,修改registry-mirro,找不到/etc/default/dcoker,/etc/sysconfig/docker

配置 Docker 镜像下载的本地 mirror 服务

Docker registry 工具现在已经很好的支持了 mirror 功能,使用它可以配置一个本地的 mirror 服务,将 pull 过的镜像 cache 在本地,这样其它主机再次 pull 的时...
  • yeasy
  • yeasy
  • 2015-07-16 19:28
  • 2054

docker删除none镜像的方法

1.先删除引用了该镜像的容器 docker ps -a(查看所有container) docker rm container_id(删除容器) 或者先用docker rmi imageid进行删除,会...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)