Docker-machine Google(GCE)驱动程序无法正常工作,无法创建实例

时间:2016-12-10 21:51:14

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

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

1:在http://console.cloud.google.com/注册新的免费GCP(Google Cloud)帐户。另请从此处下载并安装Google Cloud SDK:https://cloud.google.com/sdk/

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

3:转到" API Manager"在Google Cloud控制台中,点击"凭据"

4:点击"创建凭证"并选择"服务帐户密钥"。选择"计算引擎默认服务帐户",确保选择JSON作为输出类型,然后单击"创建"。将输出的JSON文件移动到用户根目录(/Users/MYUSERNAME)。

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

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

7:运行gcloud config set project PROJECT_ID(其中PROJECT_ID是刚刚在Google云端控制台中创建的项目的名称)。

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]

1 个答案:

答案 0 :(得分:2)

刚刚解决了这个问题。我使用了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