gpt4 book ai didi

docker - 为什么Docker中会出现 "none"镜像以及我们如何避免它

转载 作者:行者123 更新时间:2023-12-02 08:44:30 32 4
gpt4 key购买 nike

当我运行docker-compose build时命令在 Docker 中重建图像,因为我更改了 Dockerfile 中的某些内容,有时我得到“无”图像标签。我们怎样才能避免这个事实呢?我想重建图像,但图像不应出现。

REPOSITORY  TAG            IMAGE ID            CREATED             SIZE
magento2 latest b4dce4dcbd4f 16 hours ago 516MB
<none> <none> b4ffce2bf91e 16 hours ago 519MB
<none> <none> a1aedb60c82a 17 hours ago 516MB
<none> <none> ec9a14ae856c 20 hours ago 519MB
<none> <none> ef8eba6874cc 23 hours ago 516MB
<none> <none> 0e53a8b8c303 23 hours ago 516MB
php 7.1-apache 93e6fb4b13e1 3 weeks ago 369MB
mysql 5.6.39 079344ce5ebd 7 months ago 256MB

最佳答案

以下是 What are Docker <none>:<none> images? 的一些部分

The Good <none>:<none>

These are intermediate images and can be seen using docker images -a. They don't result into a disk space problem but it is definitely a screen "real estate" problem. Since all these <none>:<none> images can be quite confusing as what they signify.

The Bad <none>:<none>

These images are the dangling ones, which can cause disk space problems. These <none>:<none> images are being listed as part of docker images and need to be pruned.

(a dangling file system layer in Docker is something that is unused and is not being referenced by any images. Hence we need a mechanism for Docker to clear these dangling images)

所以,

  • 如果您的案件与dangling有关图像,可以删除它们:

     docker rmi $(docker images -f "dangling=true" -q)

    还有docker image prune的选项但客户端和守护进程 API 必须至少为 v1.25使用此命令。

  • 如果您的案件与intermediate有关图像,保留它们就可以了,其他图像指向它们的引用。

相关文档:

关于docker - 为什么Docker中会出现 "none"镜像以及我们如何避免它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53221412/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com