本文介绍了为什么“无"?图像出现在 Docker 中,我们如何避免它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

When I run the docker-compose build command to rebuild an image in Docker because I had changed something in Dockerfile, sometimes I get "none" image tags. How can we avoid this fact? I want to rebuild the image but the none image should not appear.

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

推荐答案

以下是 什么是 Docker <none>:<none> 图像?

Below are some parts from What are Docker <none>:<none> images?

这些是 intermediate 图像,可以使用 docker images -a 查看.它们不会导致磁盘空间问题,但绝对是屏幕不动产".问题.由于所有这些 <none>:<none> 图像的含义可能会让人非常困惑.

这些图像是悬空图像,可能会导致磁盘空间问题.这些 <none>:<none> 图像被列为 docker images 的一部分,需要修剪.

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.

(Docker 中的悬空文件系统层是未使用的,没有被任何镜像引用.因此我们需要一种机制让 Docker 清除这些悬空的镜像)

(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 才能使用此命令.

    There is also the option of docker image prune but the client and daemon API must both be at least v1.25 to use this command.

    如果您的案例与 intermediate 图片有关,可以保留它们,其他图片指向它们的引用.

    if your case has to do with intermediate images, it's ok to keep them, other images are pointing references to them.

    相关文档:

    这篇关于为什么“无"?图像出现在 Docker 中,我们如何避免它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 01:59