无法删除Docker映像

无法删除Docker映像

本文介绍了无法删除Docker映像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在设置新的构建机器(CentOS 7,Docker CE 17.12.0-ce)时,我做了一个简单的测试:

While setting up a new build machine (CentOS 7, Docker CE 17.12.0-ce), I did a simple test:

docker run -it --rm ubuntu bash

哪个工作正常,但现在我可以了t删除Ubuntu映像。

Which worked fine, but now I can't remove the Ubuntu image.

[build ~]$ docker image rm ubuntu
Error: No such image: ubuntu
[build ~]$ docker image rm ubuntu:latest
Error: No such image: ubuntu:latest
[build ~]$ docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              0458a4468cbc        24 hours ago        112MB
[build ~]$ docker rmi 0458a4468cbc
Error: No such image: 0458a4468cbc

任何容器都没有使用它(总之那不是错误):

It's not being used by any containers (not that that's the error anyway):

[build ~]$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
[build ~]$

我什至尝试了从轨道发射核武器方法:

I even tried the nuke-from-orbit approach:

[build ~]$ docker rmi $(docker images -q)
Error: No such image: 0458a4468cbc

然后重新启动docker守护进程:

And restarting the docker daemon:

[build ~]$ sudo systemctl restart docker
[build ~]$ docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              0458a4468cbc        24 hours ago        112MB
[build ~]$ docker rmi 0458a4468cbc
Error: No such image: 0458a4468cbc

有什么用? ubuntu映像是否存在并不重要,我只是不明白为什么我无法清理它。

What gives? Not that it really matters that the ubuntu image is there, I just don't understand why I can't clean it up.

更新

我尝试再次拉出图像,然后:

I tried pulling the image again, and, well:

docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
Digest: sha256:e27e9d7f7f28d67aa9e2d7540bdc2b33254b452ee8e60f388875e5b7d9b2b696
Status: Downloaded newer image for ubuntu:latest
[build ~]$ docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              0458a4468cbc        25 hours ago        112MB
ubuntu              latest              0458a4468cbc        25 hours ago        112MB
[build ~]$ docker image rm ubuntu
Untagged: ubuntu:latest
[build ~]$ docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              latest              0458a4468cbc        25 hours ago        112MB
[build ~]$

更新2

使用全新的CentOS 7 1708安装尝试了相同的基本步骤,完全没有问题,因此可以肯定地说这只是一次奇怪的一次性腐败在这台机器上的东西。

Tried the same basic steps with a brand new CentOS 7 1708 install and had no problems at all, so safe to say this is just a weird one-off corruption of something on this machine.

问题仍然存在,如何清理?文件系统上是否有什么东西可以让我 rm -rf 并让docker重新启动?

Question still is, how do I clean it up? Is there something on the filesystem I can just rm -rf and let docker start fresh?

推荐答案

在设置此系统时,我最初安装了可从标准CentOS存储库( yum install centos )获得的旧版本的docker,而不是添加docker存储库并安装 docker-ce 。即使我现在使用的是最新版本,旧版本也必须在升级之前在 / var / lib / docker 中引入一些不良数据。最后,我只是删除了所有本地图像和容器数据并重新开始:

While setting up this system I had originally installed an old version of docker available from the standard CentOS repositories (yum install centos) instead of adding the docker repositories and installing docker-ce. Even though I'm on the latest version now, the old one must have introduced some bad data in /var/lib/docker before I upgraded. In the end I just deleted all the local image and container data and started over:

sudo systemctl stop docker
sudo rm -rf /var/lib/docker
sudo systemctl start docker

一切正常现在。

这篇关于无法删除Docker映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 06:37