我在尝试清除Docker创建的图像时遇到了一个奇怪的问题。这就是我所做的:
删除所有容器
$ docker rm $(docker ps -a -q)
bb3927e956bf
3e2eeb6287c4
检查是否有任何容器正在运行或创建:
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
删除所有图片:第一次尝试失败,因为图片被引用
$ docker rmi $(docker images -q)
Error response from daemon: conflict: unable to delete 2f21ea981017 (must be forced) - image is referenced in one or more repositories
Error response from daemon: conflict: unable to delete 2f21ea981017 (must be forced) - image is referenced in one or more repositories
使用-f
选项删除所有图片:
$ docker rmi -f $(docker images -q)
Untagged: dev-php55:latest
Untagged: reynierpm/dev-php55:latest
Deleted: sha256:2f21ea981017f65adcf0df3764756690adc35d80538bbb6dcada12990f589f37
Deleted: sha256:7fbddc1aa50dca9bdf4f8c8033d20eca26ac00432f57333987c0eac3fe55fb08
Deleted: sha256:15883aeb774feafa64328ea2e77ebbe17a91e79ca1cd8bb2eebca60802fb01f5
Deleted: sha256:36ff96a995807763e302657eaeb671c000e58e3128a47f63bae543ba501387ed
Deleted: sha256:053f436f01f809f60ecba9fb961dfb6404dce163f84fbd905eb47a6b436ba50d
Deleted: sha256:b4525a37a105a199b7e7772de9e6ad86af645509c94c705bd13fbd422bf8f55d
Deleted: sha256:228092e34fffbb9def7f883eceea9f37fce3750d7a7d5a7551ce009410567240
Deleted: sha256:a17ed03e91cc4bef074258f731bba0945bcacc78c7ac9f00d88ca111125c94c0
Deleted: sha256:6118ff18e2049d3e13a903c4163e4e4aceea9fdd30555bdd71a1e23e8d5aa022
Deleted: sha256:b7347848822645efd3259a6c200a94c7bba15fc72b504c704e39f5db0cdca1a2
Deleted: sha256:b23b831be841f1f3cececec3e52480723d8312b464d9a89957e867fa695a4eca
Deleted: sha256:86c4c6d54d9dee52f8abe0ba8b3622b985bce68923dada61838b45860f000f44
Deleted: sha256:f053241f28e7c62ac77b44ee2f69a7bd6d2bb2ccdd9f916e43b8af88f5865f90
Deleted: sha256:3f36e15d9aac3c197472d66904fc59bd509ca36c8aa885165aadc6507f27126c
Deleted: sha256:6586309b23369f2ccb067ca456ebacd1602787960215d7c2e898c28ae6a2e78d
Deleted: sha256:43d7779d3bcd75a466df309735762f33552c2caf8f656ce1e26e1fd6b0324c49
Deleted: sha256:9e060bbbad0c042fc45eb52d3e4c41bfd30fb620459f10c62cf7e483d514e1d8
Deleted: sha256:9da9f4caedc27c128dc51d273f9d1411d6fce3f560c606fff0567d912d2d95e4
Error response from daemon: No such image: 2f21ea981017:latest
Error response from daemon: reference does not exist
然后出现这个错误:No such image: 2f21ea981017:latest
出现了,我应该问,为什么?这样的形象在哪里? Docker有哪种内部数据库存储信息?
运行所有以前的命令后,我运行以下命令并注意输出:
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 14.04.5 b1719e1db756 3 days ago 187.9 MB
但后来我尝试通过运行
再次删除图像$ docker rmi b1719e1db756
Error response from daemon: reference does not exist
我得到了同样的错误,我在这里失踪了什么?我怎么解决这个问题?
我应该补充一点,我还运行this post的命令,但没有成功。
答案 0 :(得分:2)
我在docker-ce 17.06 / fedora 26上遇到过这个问题。我认为你不需要删除docker,但是这些命令会删除你的所有图像。因此请保存您真正需要的任何图像,删除所有图像并恢复备份;
sudo systemctl stop docker.service
sudo rm -rf /var/lib/docker
sudo systemctl start docker.service
答案 1 :(得分:1)
经过一些研究以及来自Github的Docker背后的人们的大力帮助,我将自己回答。
摘要:首先,我通过运行以下命令安装docker:
$sudo dnf install docker -y
从RedHat fork安装了docker,因此版本是:1.10.3
,然后使用这个版本我构建了导致问题的图像,直到现在。构建映像后,我删除docker 1.10.3
版本并切换到docker-engine
这是官方版本并安装1.12.1
。
问题:我试图删除在docker 1.10.3下创建的图片,但是使用了docker 1.12.1,并且从那里出现了问题。
解决方案:删除docker-engine
并安装临时docker
,以便删除在此版本下创建的图片。
dnf remove docker-engine
dnf install docker
docker rmi -f $(docker images -q)
dnf remove docker
dnf install docker-engine
注意:在我按照上面显示的每个步骤后出于某种原因我遇到了以下问题:
$docker images
Error response from daemon: client is newer than server (client API version: 1.24, server API version: 1.22)
执行dnf autoremove && dnf clean all
并重新启动docker
可解决此问题。
如果您想要更多
,请随意查看here