Google Cloud Build Docker build-arg不被尊重

时间:2019-06-24 07:53:21

标签: docker google-cloud-platform google-cloud-build

我在使用Google Cloud Build时遇到问题,尽管该命令在本地运行正常,但docker build命令似乎没有接受build-arg选项。

Dockerfile:

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

1 个答案:

答案 0 :(得分:1)

好吧,修复是在云构建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" .']