Docker for Windows“已存在”映像根本不存在

CBB*_*ike 3 docker docker-machine

我正在尝试提取一个也应该提取 aspnet:4.7 图像的图像。但是 docker 一直告诉我图像“已经存在”,但事实并非如此。有没有办法告诉 Docker for Windows 无论如何都要拉取所需的图像?

PS C:\WINDOWS\system32> docker pull -a [hidden]/mycode
dev: Pulling from [hidden]/mycode
3889bb8d808b: Already exists
e29afd68a947: Already exists
36f010181129: Already exists
94c1c860b007: Already exists
d8096eabbf13: Already exists
67025ded22a8: Already exists
dbe75d79f130: Already exists
84d3d4630614: Already exists
301ba58699fa: Already exists
5e9f3c14f629: Already exists
90fd39402ca5: Already exists
4791db5edc55: Pull complete
1da86da74a58: Pull complete
3acc18896b8f: Pull complete
Digest: sha256:dc7e28154e63d5c22a210c314b4a80dcdba7baeea0ebf853445853680276293d
prod: Pulling from [hidden]/mycode
3889bb8d808b: Already exists
e29afd68a947: Already exists
36f010181129: Already exists
94c1c860b007: Already exists
d8096eabbf13: Already exists
67025ded22a8: Already exists
dbe75d79f130: Already exists
84d3d4630614: Already exists
301ba58699fa: Already exists
5e9f3c14f629: Already exists
a1fa39b61ce3: Already exists
98fa6868a880: Pull complete
10db2dd5f47b: Pull complete
5c881ba7245b: Pull complete
Digest: sha256:8b0464fe849148f4fb3c8e165cc7539823d974171bdb596bed48dd91bd9da20d
Status: Downloaded newer image for brunofvalli/xehub
PS C:\WINDOWS\system32> docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
[hidden]/mycode  dev                 6e8a0b8dd5f9        24 hours ago        11.8GB
[hidden]/mycode   prod                98a5df79a3ce        24 hours ago        11.8GB
PS C:\WINDOWS\system32>
Run Code Online (Sandbox Code Playgroud)

我试过做一个

docker rmi 3889bb8d808b
Run Code Online (Sandbox Code Playgroud)

但它告诉我图像不存在。

如何删除这些缓存的图像?或者我如何强制 Docker 下载图像?

编辑 我想我应该从这个问题开始。microsoft/aspnet:4.7 层/图像大小约为 4GB。目前,当我尝试使用此层/图像构建我的应用程序时,它失败了,我猜测它已损坏,因为在另一台机器上运行正常。我想重新获取这个基本图像,但是执行 docker rmi 并没有从我的系统中删除这个“缓存”的图像/层,所以我收到了这个已经存在的消息。我想再次重新下载 4GB 的图像。有没有办法做到这一点?我非常接近重新安装 Windows 10。

t6n*_*and 5

我认为您将图层与图像混淆了。Docker 镜像是使用 dockerfile 构建的。dockerfile 中的每一行都添加了一个构成图像的层。例如,从上面的示例中获取下面的基本 dockerfile 和层标识符:

FROM busybox:latest # ----> 3889bb8d808b
MAINTAINER person # ----> e29afd68a947
RUN touch foo.txt # ----> 36f010181129
CMD ["bin/sh"] # ------> 94c1c860b007
Run Code Online (Sandbox Code Playgroud)

这将创建一个单独的 docker 镜像,dockerfile 中的每一行构成 docker 镜像中的一个层。因此,第一行将组成一个busybox:latest带有标识符的基础图像层3889bb8d808b。随后,在与 dockerfile 行相对应的前一层之上添加更多层。这真的很有帮助,特别是当我们对 docker 文件进行更改时,更改的行将触发构建映像的速度非常快,因为与该行对应的层将被单独拉动。

同样重要的是要注意,如果某个层已经作为其他 docker 镜像的一部分存在于您的机器中,则可以直接使用它,而无需每次都再次拉取同一层。因此,在您的情况下,说已经存在的层可能是在其他图像中较早拉取的层,甚至可能是您在稍后阶段更新 dockerfile 的同一图像,因此触发层拉取仅对应于已更改的行。

因此,当您docker rmi 3889bb8d808b正确尝试docker 时,会说该图像不存在。由于3889bb8d808b标识符对应于层而不是 docker 图像。

如果您想更新 docker 镜像,请使用docker images找到与您的 Docker 镜像对应的镜像 ID,然后使用docker rmi <image-ID>. 然后使用docker pull -a brunofvalli/xehub

  • 非常感谢您的解释。我认为是我的 Windows 大脑想要获得新的层次。如果我删除所有图像并执行拉取操作,我仍然会收到“已经存在”的信息,我什至尝试卸载 docker 并重新安装,但它仍然给我这个“已经存在”的问题。有没有办法删除这些图层?它不会被 rmi 命令删除。 (2认同)