Docker-machine Google(GCE)驱动程序无法正常工作,无法创建实例 [英] Docker-machine Google (GCE) driver not working, unable to create instance

查看:546
本文介绍了Docker-machine Google(GCE)驱动程序无法正常工作,无法创建实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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



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



3:转到API管理器在Google Cloud控制台中,点击凭据



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



5:添加以下内容一行到.bash_profile config:
export GOOGLE_APPLICATION_CREDENTIALS = / Users / MYUSERNAME / NAME_OF_CREDENTIALS_FILE.json 。保存文件。



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



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



8:运行 gcloud auth登录,这将打开一个浏览器标签,将您登录到Google并授予权限。点击允许。



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



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



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



在非常漫长的输出结束时,我得到以下结果,错误信息在最底层:

 (在此之前,其他输出的LOTS不能复制,因为堆叠溢出30000 CHAR限制)

(vm01)调用.GetURL
(vm01)调用.DriverName
设置远程守护程序上的Docker配置...
(vm01)调用.GetSSHHostname
vm01)调用.GetSSHPort
(vm01)调用.GetSSHKeyPath
(vm01)调用.GetSSHKeyPath
(vm01)调用.GetSSHUse rname
使用SSH客户端类型:external
使用SSH私钥:/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>}
要运行SSH命令:
printf%s[服务]
ExecStart = / usr / bin / docker守护程序-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
环境=

[安装]
WantedBy = multiuser.target
| sudo tee /etc/systemd/system/docker.service
SSH cmd err,输出:< 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
环境=

[安装]
WantedBy = multiuser.target

(vm01)调用.GetSSHHostname
(vm01)调用.GetSSHPort
(vm01)调用.GetSSHKeyPath
(vm01)调用.GetSSHKeyPath
(vm01)调用.GetSSHUsername
使用SSH客户端类型:external
使用SSH私钥:/ 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 Con trolMaster = 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> ;}
要运行SSH命令:
sudo systemctl daemon-reload
SSH cmd err,输出:< nil> ;:
(vm01)调用.GetSSHHostname
(vm01)调用.GetSSHPort
(vm01)调用.GetSSHKeyPath
(vm01)调用.GetSSHKeyPath
(vm01)调用.GetSSHUsername
使用SSH客户端类型:external
使用SSH私钥:/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>}
要运行SSH命令:
sudo systemctl -f启动码头
SSH cmd err,输出:< nil> ;:
(vm01)调用.GetSSHHostname
(vm01)调用.GetSSHPort
(vm01)调用.GetSSHKeyPath
(vm01 )调用.GetSSHKeyPath
(vm01)调用.GetSSHUsername
使用SSH客户端类型:external
使用SSH私钥:/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>}
要运行SSH命令:
netstat -tln
SSH cmd err,输出:< nil>:活动Internet连接(仅服务器)
Proto Recv-Q Send-Q本地地址外部地址状态
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

创建机器时出错:运行配置错误:无法验证Docker守护进程正在侦听:最大重试次数(10)超过
通知bugsnag:[创建计算机时出现错误:运行配置时出现错误:无法验证Docker守护程序正在侦听:超过最大重试次数(10)]


解决方案

我使用了Google注册表(Ubuntu 16.04 LTS,而由$ code> 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


Okay, this is very easy to reproduce and incredibly frustrating. Would be super grateful for any help or advice! I'm using Docker for Mac, running on OS X El Capitan (10.11.6). The gist is that Docker seems to not work with Google Compute Engine (GCE) via the Docker GCE driver (Docker official docs reference here).

1: Sign up for a new free GCP (Google Cloud) account at http://console.cloud.google.com/. Also download and install the Google Cloud SDK from here: https://cloud.google.com/sdk/.

2: Create a new Google Cloud project.

3: Go to "API Manager" in the Google Cloud console and click on "Credentials"

4: Click on "Create Credentials" and select "Service Account Key". Select "Compute Engine default service account", make sure JSON is selected as the output type, and click "Create". Move the outputted JSON file to your user root directory (/Users/MYUSERNAME).

5: Add the following line to your .bash_profile config: export GOOGLE_APPLICATION_CREDENTIALS=/Users/MYUSERNAME/NAME_OF_CREDENTIALS_FILE.json. Save the file.

6: Exit the terminal and open up a new one so that the env variable is now set.

7: Run gcloud config set project PROJECT_ID (where PROJECT_ID is the name of the project just created in the Google Cloud Console).

8: Run gcloud auth login which will open a browser tab to log you into Google and grant permissions. Click 'Allow'.

9: Now the fun part, run the following command, per the Docker documentation (I've added a --debug flag):

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

('vm01' is the name of the virtual machine here, this could be anything you want.)

At the end of the very lengthy output I get the following, concluded by the error message at the very bottom:

(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]

解决方案

Solved this just now. I used an updated image from the Google registry (Ubuntu 16.04 LTS, versus the default Ubuntu 15 that gets used by the docker-machine --driver google command) and it seems to have worked properly. Not sure why. The full command was:

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

这篇关于Docker-machine Google(GCE)驱动程序无法正常工作,无法创建实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆