Docker for Windows "Already exists"镜像根本不存在

标签 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>

我试过做一个
docker rmi 3889bb8d808b

但它告诉我图像不存在。

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

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

最佳答案

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

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

这将创建一个单独的 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

关于Docker for Windows "Already exists"镜像根本不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45497720/

相关文章:

maven - 多 Maven 模块 Spring MVC 项目到 Spring Boot

docker - Docker 17无法在Centos 7中启动

Docker 在拉取镜像层期间永远挂起

Docker 和 Gitlab - 如何修改 docker run

python - 如何使用 Celery 从 Python 代码动态添加/停止 worker

docker - 将文件夹从 Docker 复制到主机

docker - 将 docker-machine 移动到另一台计算机

amazon-web-services - Swarm 上的多主机 Docker 组合应用程序

git - 如何解决 RHEL 容器上的 "shell request failed on channel 0"?

mysql - 端口 3306 繁忙但没有进程使用它