无法让--cache-from工作

Sau*_*nda 7 docker google-cloud-platform google-kubernetes-engine

我按照https://cloud.google.com/container-builder/docs/speeding-up-builds#using_a_cached_docker_image上的说明操作,我正在尝试设置使用上一版本缓存的图片的docker 版本.

这是我的cloudbuild.yml样子:

steps:
- name: 'gcr.io/cloud-builders/docker'
  args: ['pull', 'gcr.io/$PROJECT_ID/$REPO_NAME:infra_docker']
- name: 'gcr.io/cloud-builders/docker'
  args: ['build', '--cache-from', 'gcr.io/$PROJECT_ID/$REPO_NAME:infra_docker', '-t', 'gcr.io/$PROJECT_ID/$REPO_NAME:infra_docker', '.']
timeout: 120m
images: ['gcr.io/$PROJECT_ID/$REPO_NAME:infra_docker']
options:
  machineType: 'N1_HIGHCPU_8'
Run Code Online (Sandbox Code Playgroud)

这是我的Dockerfile开始:

FROM ubuntu:14.04
SHELL ["/bin/bash", "-c"]
# lots of RUN commands after this
Run Code Online (Sandbox Code Playgroud)

无论我尝试什么,从缓存中拉出的docker镜像(作为第一步的结果),都不用于加速实际的docker构建(第二步).它始终在我的Dockerfile中运行整个38步!

我究竟做错了什么?

Mat*_*att 4

dockerfile 是多阶段的吗?我遇到了这个问题,只有最终图像可用于缓存。根据您运行的步骤,这可能看起来好像没有步骤正在使用缓存。如果是这种情况,您还需要将中间映像推送到容器注册表,并在构建时拉取它们。