Google Cloud Build Docker build-arg 不被尊重

Google Cloud Build Docker build-arg not respected

我在使用 Google Cloud Build 时遇到问题,其中 docker build 命令似乎不接受 build-arg 选项,即使同一命令在本地:

Docker 文件:

ARG ASSETS_ENV=development
RUN echo "ASSETS_ENV is ${ASSETS_ENV}"

构建命令:

docker build --build-arg="ASSETS_ENV=production" .

本地结果:

ASSETS_ENV is production

云构建结果:

ASSETS_ENV is development

好的,修复在云构建 yaml 配置中:

之前:

- name: 'gcr.io/cloud-builders/docker'
  args: ['build', '--build-arg="ASSETS_ENV=production"', '.']

之后:

- name: 'gcr.io/cloud-builders/docker'
  entrypoint: 'bash'
  args: ['-c', 'docker build --build-arg="ASSETS_ENV=production" .']

对于像这样定义他们的步骤的任何人:

- name: 'gcr.io/cloud-builders/docker'
  args:
  - build
  - foo
  - bar

@nader-ghanbari 的评论对我有用:

- name: 'gcr.io/cloud-builders/docker'
  args:
  - build
  - --build-arg
  - TF2_BASE_IMAGE=${_TF2_BASE_IMAGE}