2

在给定此 Dockerfile的 Docker for Mac 1.12.3上:

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
4

1 回答 1

3

我找到了解决办法!

在我的撰写文件中,我使用:dns: 8.8.8.8现在它可以完美运行。

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

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

于 2016-11-19T19:08:58.893 回答