【发布时间】:2020-11-12 01:01:58
【问题描述】:
我尝试将文件从正在运行的 docker 容器复制到 google 存储桶
Cloud Resource API 在我的 GCP 项目中启用
我尝试从笔记本电脑上的本地 docker 执行的命令:
gsutil cp README gs://<my_bucket>/<folder>/
我得到的错误如下所示
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
我的Dockerfile 配置
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>
是否缺少任何配置?
【问题讨论】:
-
您是否尝试评论 boto 行?您可能会对此感到困惑。
-
是否可以尝试删除 boto 行是否可以解决问题?
-
@guillaumeblaquiere 谢谢!工作
-
@JoseV 谢谢提醒!
-
@Toren。如果他们有类似的问题,我只是回答以帮助其他人找到答案。
标签: docker google-app-engine google-cloud-platform google-authentication