[英]Google Cloud Builder shell variables propagation
我有以下 Dockerfile:
Dockerfile
FROM ubuntu
ENTRYPOINT echo "Hello, $MY_ENV"
這是構建和推動的:
> docker build --platform linux/amd64 -f Dockerfile . --tag gcr.io/my_project/hello_world_shell
> docker push gcr.io/my_project/hello_world_shell
當我在本地運行圖像並傳遞MY_ENV
和 env 變量時,它按預期工作:
> docker run -e MY_ENV=World --rm gcr.io/my_project/hello_world_shell
Hello, World
但是當我嘗試在 Cloud Build 中運行它時,無法識別MY_ENV
變量。
cloudbuild.yaml
steps:
- name: 'gcr.io/cloud-builders/docker'
args:
- 'run'
- '-e MY_ENV=World'
- '--rm'
- 'gcr.io/my_project/hello_world_shell'
id: 'run docker container'
waitFor: ['-']
> gcloud builds submit --config cloudbuild.yaml
...
Status: Downloaded newer image for gcr.io/my_project/hello_world_shell:latest
Hello,
PUSH
DONE
Cloud Builder 中的變量傳播有什么問題?
好的,看起來-e
附近的這個空間是額外的:
steps:
- name: 'gcr.io/cloud-builders/docker'
args:
- 'run'
- '-eMY_ENV=World' ### <---- this
- '--rm'
- 'gcr.io/my_project/hello_world_shell'
id: 'run docker container'
waitFor: ['-']
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.