【问题标题】:Docker-machine Google (GCE) driver not working, unable to create instanceDocker-machine Google (GCE) 驱动程序不工作,无法创建实例
【发布时间】:2017-04-26 03:05:37
【问题描述】:

好的,这很容易重现,而且非常令人沮丧。将非常感谢任何帮助或建议!我正在使用 Docker for Mac,在 OS X El Capitan (10.11.6) 上运行。要点是 Docker 似乎无法通过 Docker GCE 驱动程序与 Google Compute Engine (GCE) 一起使用(Docker 官方文档参考 here)。

1:在http://console.cloud.google.com/ 注册一个新的免费 G​​CP (Google Cloud) 帐户。也可以从这里下载并安装 Google Cloud SDK:https://cloud.google.com/sdk/

2:创建一个新的 Google Cloud 项目。

3:进入谷歌云控制台中的“API Manager”,点击“Credentials”

4:点击“Create Credentials”并选择“Service Account Key”。选择“Compute Engine 默认服务帐户”,确保选择 JSON 作为输出类型,然后单击“创建”。将输出的 JSON 文件移动到您的用户根目录 (/Users/MYUSERNAME)。

5:将以下行添加到您的 .bash_profile 配置中: export GOOGLE_APPLICATION_CREDENTIALS=/Users/MYUSERNAME/NAME_OF_CREDENTIALS_FILE.json。保存文件。

6:退出终端并打开一个新终端,以便设置环境变量。

7:运行gcloud config set project PROJECT_ID(其中 PROJECT_ID 是刚刚在 Google Cloud Console 中创建的项目的名称)。

8:运行gcloud auth login,这将打开一个浏览器选项卡,让您登录 Google 并授予权限。点击“允许”。

9:现在有趣的部分,根据 Docker documentation 运行以下命令(我添加了一个 --debug 标志):

docker-machine --debug create --driver google --google-project PROJECT_ID vm01

('vm01' 是这里的虚拟机名称,可以是你想要的任何名称。)

在非常冗长的输出结束时,我得到以下内容,并以最底部的错误消息结束:

(LOTS OF OTHER OUTPUT BEFORE THIS, NOT ABLE TO COPY-PASTE EVERYTHING DUE TO STACKOVERFLOW 30000 CHAR LIMIT)

(vm01) Calling .GetURL
(vm01) Calling .DriverName
Setting Docker configuration on the remote daemon...
(vm01) Calling .GetSSHHostname
(vm01) Calling .GetSSHPort
(vm01) Calling .GetSSHKeyPath
(vm01) Calling .GetSSHKeyPath
(vm01) Calling .GetSSHUsername
Using SSH client type: external
Using SSH private key: /Users/nathan/.docker/machine/machines/vm01/id_rsa (-rw-------)
&{[-F /dev/null -o PasswordAuthentication=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -o ConnectionAttempts=3 -o ConnectTimeout=10 -o ControlMaster=no -o ControlPath=none docker-user@104.198.166.134 -o IdentitiesOnly=yes -i /Users/nathan/.docker/machine/machines/vm01/id_rsa -p 22] /usr/bin/ssh <nil>}
About to run SSH command:
printf %s "[Service]
ExecStart=/usr/bin/docker daemon -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --storage-driver aufs --tlsverify --tlscacert /etc/docker/ca.pem --tlscert /etc/docker/server.pem --tlskey /etc/docker/server-key.pem --label provider=google
MountFlags=slave
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
Environment=

[Install]
WantedBy=multi-user.target
" | sudo tee /etc/systemd/system/docker.service
SSH cmd err, output: <nil>: [Service]
ExecStart=/usr/bin/docker daemon -H tcp://0.0.0.0:2376 -H unix:///var/run/docker.sock --storage-driver aufs --tlsverify --tlscacert /etc/docker/ca.pem --tlscert /etc/docker/server.pem --tlskey /etc/docker/server-key.pem --label provider=google
MountFlags=slave
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
Environment=

[Install]
WantedBy=multi-user.target

(vm01) Calling .GetSSHHostname
(vm01) Calling .GetSSHPort
(vm01) Calling .GetSSHKeyPath
(vm01) Calling .GetSSHKeyPath
(vm01) Calling .GetSSHUsername
Using SSH client type: external
Using SSH private key: /Users/nathan/.docker/machine/machines/vm01/id_rsa (-rw-------)
&{[-F /dev/null -o PasswordAuthentication=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -o ConnectionAttempts=3 -o ConnectTimeout=10 -o ControlMaster=no -o ControlPath=none docker-user@104.198.166.134 -o IdentitiesOnly=yes -i /Users/nathan/.docker/machine/machines/vm01/id_rsa -p 22] /usr/bin/ssh <nil>}
About to run SSH command:
sudo systemctl daemon-reload
SSH cmd err, output: <nil>:
(vm01) Calling .GetSSHHostname
(vm01) Calling .GetSSHPort
(vm01) Calling .GetSSHKeyPath
(vm01) Calling .GetSSHKeyPath
(vm01) Calling .GetSSHUsername
Using SSH client type: external
Using SSH private key: /Users/nathan/.docker/machine/machines/vm01/id_rsa (-rw-------)
&{[-F /dev/null -o PasswordAuthentication=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -o ConnectionAttempts=3 -o ConnectTimeout=10 -o ControlMaster=no -o ControlPath=none docker-user@104.198.166.134 -o IdentitiesOnly=yes -i /Users/nathan/.docker/machine/machines/vm01/id_rsa -p 22] /usr/bin/ssh <nil>}
About to run SSH command:
sudo systemctl -f start docker
SSH cmd err, output: <nil>:
(vm01) Calling .GetSSHHostname
(vm01) Calling .GetSSHPort
(vm01) Calling .GetSSHKeyPath
(vm01) Calling .GetSSHKeyPath
(vm01) Calling .GetSSHUsername
Using SSH client type: external
Using SSH private key: /Users/nathan/.docker/machine/machines/vm01/id_rsa (-rw-------)
&{[-F /dev/null -o PasswordAuthentication=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -o ConnectionAttempts=3 -o ConnectTimeout=10 -o ControlMaster=no -o ControlPath=none docker-user@104.198.166.134 -o IdentitiesOnly=yes -i /Users/nathan/.docker/machine/machines/vm01/id_rsa -p 22] /usr/bin/ssh <nil>}
About to run SSH command:
netstat -tln
SSH cmd err, output: <nil>: Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 10.0.3.1:53             0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp6       0      0 :::22                   :::*                    LISTEN

Error creating machine: Error running provisioning: Unable to verify the Docker daemon is listening: Maximum number of retries (10) exceeded
notifying bugsnag: [Error creating machine: Error running provisioning: Unable to verify the Docker daemon is listening: Maximum number of retries (10) exceeded]

【问题讨论】:

    标签: docker google-cloud-platform google-compute-engine docker-machine


    【解决方案1】:

    刚刚解决了这个问题。我使用了来自 Google 注册表的更新图像(Ubuntu 16.04 LTS,与 docker-machine --driver google 命令使用的默认 Ubuntu 15 相比),它似乎运行正常。不知道为什么。完整的命令是:

    docker-machine --debug create --driver google --google-project PROJECT_ID --google-machine-image https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-1604-xenial-v20161205 vm02

    【讨论】:

    • 我喜欢使用更新映像的想法,但对我来说(OS X,docker-machine 0.8.2,docker 1.12.3),它会出错,并带有 `` About to run SSH命令:cat /etc/os-release SSH cmd err,输出:退出状态 255:创建机器时出错:检测操作系统时出错:获取 SSH 命令时出错:运行 SSH 命令时出错!命令:cat /etc/os-release err:退出状态 255 输出:选择退出崩溃报告。 ```
    • 确保 1) 将上面的 PROJECT_ID 替换为您的项目的实际名称,2) 首先执行 gcloud auth login,以及 3) 首先下载 JSON 凭据文件(参见上面的原始帖子)并指向它与 GOOGLE_APPLICATION_CREDENTIALS 环境变量。
    • 谢谢。我现在可以创建一个 docker-machine 实例。我最初是在试图找出为什么我无法使用eval $(docker-machine env vm01) 将其设置为活动时发现这篇文章的。该命令的响应是Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "&lt;external IP of GCE VM&gt;:2376": tls: DialWithDialer timed out You can attempt to regenerate them using 'docker-machine regenerate-certs [name]'. Be advised that this will trigger a Docker daemon restart which will stop running containers.
    • 是的,和我一样。然后我尝试像它说的那样重新生成它们,并得到一个错误,说 Docker 守护程序甚至没有在主机上运行。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-23
    • 2019-02-08
    相关资源
    最近更新 更多