I am trying to build an image based on gcr.io/google.com/cloudsdktool/cloud-sdk:alpine
, with some configuration I already know on build time. After some testing with gcloud config set
on my local system, I transposed these commands into my Dockerfile. Although the sequence of commands yields the expected final gcloud configuration on my computer, the behaviour I found on the docker image was different and no change was persisted after the RUN
commands.
I didn't expect this behaviour. What should explain this?
I used the following Dockerfile to assess the issue during troubleshoot:
FROM gcr.io/google.com/cloudsdktool/cloud-sdk:alpine AS runner
RUN ["gcloud", "config", "list"]
RUN ["gcloud", "config", "set", "compute/region", "europe-west1"]
RUN ["gcloud", "config", "list"]
ENTRYPOINT [ "bash" ]
One can see that step 2/5 and step 4/5 yield the same output, even though the step 3/4 should change the current gcloud configuration for compute/region
.
$ docker build --no-cache .
Sending build context to Docker daemon 2.048kB
Step 1/5 : FROM gcr.io/google.com/cloudsdktool/cloud-sdk:alpine AS runner
---> e3ce7ea1a190
Step 2/5 : RUN ["gcloud", "config", "list"]
---> Running in b8fb806b04aa
[component_manager]
disable_update_check = true
[core]
disable_usage_reporting = true
[metrics]
environment = github_docker_image
Your active configuration is: [default]
Removing intermediate container b8fb806b04aa
---> bc8321e71e60
Step 3/5 : RUN ["gcloud", "config", "set", "compute/region", "europe-west1"]
---> Running in cfbcb80b1a31
Updated property [compute/region].
Removing intermediate container cfbcb80b1a31
---> db76ee7c5e60
Step 4/5 : RUN ["gcloud", "config", "list"]
---> Running in d90c64fcf0b0
[component_manager]
disable_update_check = true
[core]
disable_usage_reporting = true
[metrics]
environment = github_docker_image
Your active configuration is: [default]
Removing intermediate container d90c64fcf0b0
---> a593aa61055e
Step 5/5 : ENTRYPOINT [ "bash" ]
---> Running in acb4d360754c
Removing intermediate container acb4d360754c
---> edab55257026
Successfully built edab55257026
cloud-builders https://github.com/GoogleCloudPlatform/cloud-builders/tree/master/gcloud