docker - Docker 镜像构建以悬空镜像结束
问题描述
我的 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
as 选项传递给构建命令才能标记它们。
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/
请注意:如果您使用相同的标签重新标记另一张图像,也可能会发生未标记的图像,也就是说,从现有图像中窃取标签,使旧图像未标记。
这将显示未标记的图像,它们是图像树的叶子(不是中间层)。当新构建的图像
repo:tag
从图像 ID 中移除,将其保留为原样<none>:<none>
或未标记时,就会出现这些图像。如果在容器当前正在使用图像时尝试删除图像,则会发出警告。通过具有此标志,它允许进行批量清理。
来源:https ://docs.docker.com/engine/reference/commandline/images/#filtering
推荐阅读
- java - 我应该如何在android studio中使用java将从intent读取的内容存储到一个字符串中?
- c# - 如何使用 Autofac 注册 DbContextPool?
- reactjs - 如何使用 craco config 在 webpack 中禁用 babel-loader?
- python - PyInstaller 无法使用 google.cloud vision 导入生成 exe 文件
- javascript - ComponentDidMount 在我的情况下没有触发
- javascript - 当我选择下拉值时,需要添加它并且必须相应地更新价格
- java - 在您的类路径错误中找不到命令
- python - .click() 按钮在 Selenium python 中什么都不做
- reactjs - Gatsby:Puppeteer 导致 TimeoutError:超过 30000 毫秒的导航超时
- react-native - 是否可以避免在 Sentry 中收集特定数据?