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

Docker gsutil:无法在www.googleapis.com上找到服务器,docker,google-cloud-storage,google-cloud-platform,gsutil,docker-for-mac,Docker,Google Cloud Storage,Google Cloud Platform,Gsutil,Docker For Mac,在Mac 1.12.3的Docker上,给定此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-opens

在Mac 1.12.3的Docker上,给定此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
这里提出了一些修复方案,如:

它修复了
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
我的身份验证方法是使用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
我找到了解决办法

在我的compose文件中,我使用了:
dns:8.8.8
,现在它工作得很好

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


可能是Docker networking/DNS中的错误?

在完成此设置后,curl是否可以访问www.googleapis.com?我想是的,因为curl从dl.google.com检索到了gcloud包。比较gsutil-D和curl的HTTP请求输出,看看有什么不同,可能会很有用。如果curl不起作用,那么这是检查网络的一个很好的起点。@TravisHobrla我有一个预感,这是python HTTP客户端及其使用的证书的问题。设置
custom\u ca\u certs\u文件
会修复gcloud CLI,但不会修复gsutil
curl
ing会像预期的那样导致登录错误。这是有道理的。gsutil不使用gcloud的证书文件配置。您是否可以尝试通过添加到~/.boto
[boto]ca\u certificates\u file=/path/to/file
来为gsutil设置ca certs文件(需要在[boto]之后换行,但StackOverflow不允许在注释中换行)@TravisHobrla尝试了这一点,但没有成功。gsutil-D的HTTP请求输出和指向同一端点的curl之间还有其他区别吗?如果没有,你能给gs发邮件吗-team@google.com有了gsutil-D日志,我就可以跟你联系了?很高兴听到这个消息!我已经更新了你的解决方案,以防其他人在将来遇到这些DNS问题。我甚至没有使用docker。在我的mac电脑上仍然出现这个错误。我将
8.8.8.8
DNS添加到系统设置中。问题解决了。
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