谷歌云构建Docker构建参数不受尊重

谷歌云构建Docker构建参数不受尊重,docker,google-cloud-platform,google-cloud-build,Docker,Google Cloud Platform,Google Cloud Build,我在Google Cloud Build中遇到了一个问题,docker Build命令似乎不接受Build arg选项,即使该命令在本地上也能正常工作: ASSETS_ENV is production Dockerfile: ARG ASSETS_ENV=development RUN echo "ASSETS_ENV is ${ASSETS_ENV}" 生成命令: docker build --build-arg="ASSETS_ENV=production" . 本地测试结果: AS

我在Google Cloud Build中遇到了一个问题,docker Build命令似乎不接受Build arg选项,即使该命令在本地上也能正常工作:

ASSETS_ENV is production
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

好的,修复程序位于云构建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" .']

顺便问一下,有人知道为什么前一种解决方案不起作用吗?