docker强制删除none的image镜像

昨晚使用dockerfile生成一个镜像,中途断网了,导致images的REPOSITORY出现<none>

他的名字和tag都是为none

错误提示:

1
Failed to remove image (bceaae03d0ea): Error response from daemon: conflict: unable to delete bceaae03d0ea (must be forced) - image is being used by stopped container 31142aabc63c

首先我查看镜像

再查看容器,包括运行后退出的。

#引起上面的原因是docker官方要求,docker rmi image_id 只能删除未被使用的image。

由上面这段话,我推断到有容器在使用这个镜像,所以没法删除。

排除方法:1、删除和bceaae03d0ea镜像有关联的容器  2、再重新删除镜像

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
查看镜像
[root@salt-master ~] # docker images 
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
<none>                  <none>              bceaae03d0ea        15 hours ago        172 MB
516249940 /centos6-ssh    v1                  f6bb69ea7020        19 hours ago        556.4 MB
centos6- ssh              latest              f6bb69ea7020        19 hours ago        556.4 MB
docker.io /centos         centos6             8315978ceaaa        4 weeks ago         194.6 MB
docker.io /ubuntu         12.10               3e314f95dcac        2 years ago         172 MB
查看所有容器
[root@salt-master ~] # docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS                   NAMES
31142aabc63c        bceaae03d0ea         "/bin/sh -c 'apt-get "    15 hours ago        Exited (100) 15 hours ago                           drunk_borg
f8aa111d0066        centos6- ssh          "/usr/sbin/sshd -D"       18 hours ago        Up 18 hours                 0.0.0.0:32768->22 /tcp    my-first-docker
[root@salt-master ~] # docker ps -l
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS               NAMES
31142aabc63c        bceaae03d0ea         "/bin/sh -c 'apt-get "    15 hours ago        Exited (100) 15 hours ago                       drunk_borg
[root@salt-master ~] #
1
2
[root@salt-master ~] # docker ps -a |grep bceaae03d0ea
31142aabc63c        bceaae03d0ea         "/bin/sh -c 'apt-get "    15 hours ago        Exited (100) 15 hours ago                           drunk_borg
1
2
3
4
5
6
7
8
9
10
11
12
[root@salt-master ~] # docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS                   NAMES
31142aabc63c        bceaae03d0ea         "/bin/sh -c 'apt-get "    15 hours ago        Exited (100) 15 hours ago                           drunk_borg
f8aa111d0066        centos6- ssh          "/usr/sbin/sshd -D"       18 hours ago        Up 18 hours                 0.0.0.0:32768->22 /tcp    my-first-docker
删除已经退出运行的容器
[root@salt-master ~] # docker ps -a | grep "Exited" | awk '{print $1 }'|xargs docker rm
31142aabc63c
[root@salt-master ~]
[root@salt-master ~]
[root@salt-master ~] # docker ps -a
CONTAINER ID        IMAGE               COMMAND               CREATED             STATUS              PORTS                   NAMES
f8aa111d0066        centos6- ssh          "/usr/sbin/sshd -D"    18 hours ago        Up 18 hours         0.0.0.0:32768->22 /tcp    my-first-docker
1
2
3
4
5
6
7
8
9
10
11
12
13
14
删除none镜像
[root@salt-master ~] # docker images |grep none
<none>                  <none>              bceaae03d0ea        15 hours ago        172 MB
[root@salt-master ~] # docker images |grep none |awk '{print $3}'
bceaae03d0ea
[root@salt-master ~] # docker images |grep none |awk '{print $3}'|xargs docker rmi
Deleted: sha256:bceaae03d0ea6312608c6a9f310bcaa0b4363792fba6ee4875e1d2b9c7c1fbb1
[root@salt-master ~] # docker images 
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
516249940 /centos6-ssh    v1                  f6bb69ea7020        19 hours ago        556.4 MB
centos6- ssh              latest              f6bb69ea7020        19 hours ago        556.4 MB
docker.io /centos         centos6             8315978ceaaa        4 weeks ago         194.6 MB
docker.io /ubuntu         12.10               3e314f95dcac        2 years ago         172 MB
[root@salt-master ~] #
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值