docker使用问题整理
镜像处理相关
1.无法删除所有镜像,提示如下
[@localhost:~]$ docker rmi $(docker images -q)
Error response from daemon: conflict: unable to delete af2f74c517aa (must be forced) - image is referenced in multiple repositories
Error response from daemon: conflict: unable to delete af2f74c517aa (must be forced) - image is referenced in multiple repositories
出现上面问题的原因:
对于被删除的ImageID,这里存在多个REPOSITORY名字引用,解决方法如下:
[@localhost:~]$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
busybox latest af2f74c517aa 5 weeks ago 1.2MB
test-docker-hub.dding.net/admin/busybox latest af2f74c517aa 5 weeks ago 1.2MB
test-docker-hub.dding.net/admin/wuxiaoyu latest af2f74c517aa 5 weeks ago 1.2MB
test-docker-hub.dding.net/busybox latest af2f74c517aa 5 weeks ago 1.2MB
[@localhost:~]$ docker rmi test-docker-hub.dding.net/busybox:latest
Untagged: test-docker-hub.dding.net/busybox:latest
[@localhost:~]$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
busybox latest af2f74c517aa 5 weeks ago 1.2MB
test-docker-hub.dding.net/admin/busybox latest af2f74c517aa 5 weeks ago 1.2MB
test-docker-hub.dding.net/admin/wuxiaoyu latest af2f74c517aa 5 weeks ago 1.2MB
[@localhost:~]$
即删除时指定名称,而不是IMAGE ID
2.无法删除被stop container引用的image,提示如下
[@localhost:~]$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
busybox latest af2f74c517aa 5 weeks ago 1.2MB
[@localhost:~]$ docker rmi af2f74c517aa
Error response from daemon: conflict: unable to delete af2f74c517aa (must be forced) - image is being used by stopped container ce1cd38f5311
[@localhost:~]$
解决方法:
[@localhost:~]$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ce1cd38f5311 busybox "/bin/sh" About an hour ago Exited (130) 11 minutes ago distracted_lalande [@localhost:~]$ [@localhost:~]$ docker rm ce1cd38f5311 #删除容器 ce1cd38f5311 [@localhost:~]$ docker rmi busybox #删除镜像 Untagged: busybox:latest Untagged: busybox@sha256:954e1f01e80ce09d0887ff6ea10b13a812cb01932a0781d6b0cc23f743a874fd Deleted: sha256:af2f74c517aac1d26793a6ed05ff45b299a037e1a9eefeae5eacda133e70a825 Deleted: sha256:0b97b1c81a3200e9eeb87f17a5d25a50791a16fa08fc41eb94ad15f26516ccea [@localhost:~]$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE [@localhost:~]$
即先删除容器,然后删除镜像。

浙公网安备 33010602011771号