gsutil:无法在www.googleapis.com上找到该服务器

时间:2016-11-15 20:43:02

标签: docker google-cloud-storage google-cloud-platform gsutil docker-for-mac

Docker for Mac 1.12.3 上给出此Dockerfile:

FROM debian:jessie
ENV DEBIAN_FRONTEND=noninteractive

RUN \
  apt-get update && \
  apt-get install --no-install-recommends --fix-missing -y -q \
    ca-certificates \
    curl \
    python \
    python-openssl \
    && \
  apt-get clean autoclean && \
  apt-get autoremove -y && \
  rm -rf /var/lib/{apt,dpkg,cache,log}/

ENV GOOGLE_CLOUD_SDK=/google-cloud-sdk
ENV PATH=$PATH:$GOOGLE_CLOUD_SDK/bin
RUN \
  export GOOGLE_SDK_URL=https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-sdk-134.0.0-linux-x86_64.tar.gz && \
  mkdir $GOOGLE_CLOUD_SDK && \
  curl --silent $GOOGLE_SDK_URL | tar xvzf - -C $GOOGLE_CLOUD_SDK --strip-components=1 && \
  gcloud init

运行

docker build -t gsutil .

将产生

Welcome! This command will take you through the configuration of gcloud.

Your current configuration has been set to: [default]

You can skip diagnostics next time by using the following flag:
  gcloud init --skip-diagnostics

Network diagnostic detects and fixes local network connection issues.
Checking network connection..................done.
ERROR: Reachability Check failed.
    Cannot reach https://cloudresourcemanager.googleapis.com/v1beta1/projects (ServerNotFoundError)
    Cannot reach https://www.googleapis.com/auth/cloud-platform (ServerNotFoundError)
    Cannot reach https://dl.google.com/dl/cloudsdk/channels/rapid/components-2.json (ServerNotFoundError)
Network connection problems may be due to proxy or firewall settings.


Do you have a network proxy you would like to set in gcloud (Y/n)?
Select the proxy type:
 [1] HTTP
 [2] HTTP_NO_TUNNEL
 [3] SOCKS4
 [4] SOCKS5
Please enter your numeric choice:
ERROR: Network diagnostic (0/1 checks) failed.

Network errors detected.

Would you like to continue anyways (y/N)?
You can re-run diagnostics with the following command:
  gcloud info --run-diagnostics

这里提出了一些修正案https://code.google.com/p/google-cloud-sdk/issues/detail?can=2&q=&colspec=ID%20Type%20Status%20Priority%20Milestone%20Owner%20Stars%20Summary%20log&groupby=&sort=&id=1146,如:

gcloud config set custom_ca_certs_file /etc/ssl/certs/ca-certificates.crt

哪个修复了gcloud init失败,但当我尝试使用gsutil操作我的任何存储桶时,我得到了:

DEBUG 1115 20:39:17.746218 http_wrapper.py] Caught server not found error, retrying: Unable to find the server at www.googleapis.com

我的身份验证方法是activate-service-account,其中包含JSON密钥,如下所示:

COPY ./mykey.json ./mykey.json
RUN gcloud auth activate-service-account --key-file=mykey.json

任何想法如何解决这个问题?

- 更新 -

我从dockerfile支持了一个图像并将其推送到Docker Hub。要重现此问题,请下载GS密钥并将其重命名为key.json并运行:

docker run -it --rm -v $(pwd)/key.json:/key.json kilianciuffolo/gsutil bash
root@905045dd14eb:/# gcloud auth activate-service-account --key-file=/key.json && gsutil -D ls gs://my-test-bucket

1 个答案:

答案 0 :(得分:1)

我找到了解决办法!

在我的撰写文件中,我使用:dns: 8.8.8.8,现在效果很好。

奇怪的是,在我的主机macOS 10.12.1上使用Docker for Mac 0.12.3我已经在使用谷歌DNS了。

可能是Docker网络/ DNS中的错误?