为什么“无”?镜像出现在Docker中以及如何避免 [英] Why the "none" image appears in Docker and how can we avoid it

查看:292
本文介绍了为什么“无”?镜像出现在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?


善良的< none> ::< none>


这些是中间图片,可以使用 docker images -a 查看。它们不会导致磁盘空间问题,但肯定是屏幕空间问题。由于所有这些< none> ::< none> 图片在其含义上可能会非常混乱。

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.

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

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)


因此,



  • 如果您的情况与<$ c $有关c>悬空图像,可以将其删除,操作如下:

    So,

    • if your case has to do with dangling images, it's ok to remove them with:

       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.

      如果您的案例与中间图像有关,可以保留它们,其他图像指向它们的引用。

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

      相关文档:

      • docker rmi
      • docker image rm
      • docker image prune

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆