【问题标题】:Multistage docker build with no-cache无缓存的多阶段 docker 构建
【发布时间】:2020-04-16 22:21:34
【问题描述】:

我有一个多级 Dockerfile,如下所示。当 Dockerfile 中引用的映像之一更新时,如何确保在基于此 Dockerfile 构建映像时再次拉取最新版本/始终拉取最新版本。使用 --no-cache 运行 docker build 命令仍然引用旧版本的映像,但实际上并没有从 docker 注册表中提取最新版本。

docker build --no-cache -t test_deploy -f Dockerfile
FROM myreg.abc.com/testing_node:latest AS INITIMG
....
....
RUN npm install
RUN npm run build

FROM myreg.abc.com/testing_nginx:latest

COPY --from=INITIMG /sourcecode/build/ /usr/share/nginx/html
CMD ["nginx", "-g", "daemon off;"]

【问题讨论】:

    标签: docker dockerfile docker-registry docker-multi-stage-build


    【解决方案1】:

    --no-cache 告诉 docker 不要重用缓存层。如果它们已经在本地存在,它不会拉取图像。 您可以在构建之前docker pull myreg.abc.com/testing_node:latest,或者更方便的是,在调用docker build 时也可以添加--pull

    https://docs.docker.com/engine/reference/commandline/build/#options

    【讨论】:

      猜你喜欢
      • 2019-03-12
      • 2019-03-09
      • 2020-03-19
      • 1970-01-01
      • 1970-01-01
      • 2020-07-13
      • 2022-11-25
      • 2019-09-27
      • 1970-01-01
      相关资源
      最近更新 更多