I try to copy a file from running docker container to google bucket
the Cloud Resource API
is enabled in my GCP project
The command I try to execute from the local docker located on my laptop:
gsutil cp README gs://<my_bucket>/<folder>/
the error I get looks like following
Copying file://README [Content-Type=application/octet-stream]...
Your "GCE" credentials are invalid. Please run
$ gcloud auth login
apitools.base.py.exceptions.ResourceUnavailableError: GCE credentials requested outside a GCE instance
My Dockerfile
configuration
FROM python:3.6.11
WORKDIR /root
# Installs google cloud sdk, this is mostly for using gsutil to export model.
RUN wget -nv \
https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz && \
mkdir /root/tools && \
tar xvzf google-cloud-sdk.tar.gz -C /root/tools && \
rm google-cloud-sdk.tar.gz && \
/root/tools/google-cloud-sdk/install.sh --usage-reporting=false \
--path-update=false --bash-completion=false \
--disable-installation-options && \
rm -rf /root/.config/* && \
ln -s /root/.config /config && \
# Remove the backup directory that gcloud creates
rm -rf /root/tools/google-cloud-sdk/.install/.backup
# Path configuration
ENV PATH $PATH:/root/tools/google-cloud-sdk/bin
# Make sure gsutil will use the default service account
RUN echo '[GoogleCompute]\nservice_account = default' > /etc/boto.cfg
COPY config/goog.json /usr/src/config/key_file.json
# setup GCP credentials
ENV GOOGLE_APPLICATION_CREDENTIALS=/usr/src/config/key_file.json
RUN gcloud auth activate-service-account --key-file=/usr/src/config/key_file.json && \
gcloud --quiet config set compute/zone us-central1-a && \
gcloud --quiet config set project <my_project_name>
Any configuration is missing ?
The boto configuration override the env var definition and it doesn't take into account when your gsutil command is called.
Deleting it solve the problem.