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

gsutil: Unable to find the server at www.googleapis.com

Docker 上 Mac 1.12.3 鉴于此 Docker 文件:

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

我找到了修复方法!

在我的撰写文件中,我使用了:dns: 8.8.8.8,现在它运行良好。

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

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