gpt4 book ai didi

docker - Docker镜像构建最终以悬挂的镜像结束

转载 作者:行者123 更新时间:2023-12-02 18:13:12 25 4
gpt4 key购买 nike

我的Dockerfile:

FROM ubuntu:latest

ENV STAR_VERSION=2.7.3a
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
&& apt-get install -y git-all \
&& apt-get install -y --no-install-recommends apt-utils \
&& apt-get install -y --no-install-recommends build-essential \
&& apt-get install -y make \
&& apt-get install -y libz.dev \
&& echo "downloading ${STAR_VERSION}"

WORKDIR /mnt/d/github/Docker/STAR_2.7.3a/

RUN git clone https://github.com/alexdobin/STAR.git \
&& cd STAR/source \
&& echo "making STAR ${STAR_VERSION}" \
&& make STAR

CMD ["STAR", "--version"]

建立图片:
docker image build .

它显示它已成功构建(尽管有一些警告),但是当我检查它时
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> e57297dc089d 29 minutes ago 1.41GB
<none> <none> 8c4d6c6be0d2 About an hour ago 915MB
<none> <none> a2625623ebb7 2 hours ago 754MB
$ docker image ls --filter dangling=true
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> e57297dc089d 30 minutes ago 1.41GB
<none> <none> 8c4d6c6be0d2 About an hour ago 915MB
<none> <none> a2625623ebb7 2 hours ago 754MB

为什么它们都单薄而没有标签?

最佳答案

默认情况下,您从Dockerfile生成的镜像是未加标签的,并且是未修饰的。

您需要将repo:tag作为选项传递给build命令以对其进行标记。

docker image build --tag some/repo:tag . 

从文档中:
--tag , -t      Name and optionally a tag in the ‘name:tag’ format

资料来源: https://docs.docker.com/engine/reference/commandline/image_build/

请注意:带有未标记图像的情况也可能发生,如果您使用相同标签重新标记了另一个图像,也就是说,从现有图像中窃取了该标签,而使旧图像未标记。

This will display untagged images that are the leaves of the images tree (not intermediary layers). These images occur when a new build of an image takes the repo:tag away from the image ID, leaving it as <none>:<none> or untagged. A warning will be issued if trying to remove an image when a container is presently using it. By having this flag it allows for batch cleanup.



资料来源: https://docs.docker.com/engine/reference/commandline/images/#filtering

关于docker - Docker镜像构建最终以悬挂的镜像结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62010511/

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