Docker-machine使用通用驱动程序创建,证书不工作但SSH工作

我试图在我们的网络中的Ubuntu 14.04TSL服务器上启动并运行一个docker-machine.我在服务器上安装了docker docker-machine,并且能够使用我的计算机上的这个命令在服务器上创建docker-machine:

docker-machine create --driver generic --generic-ip-address 10.10.3.76 --generic-ssh-key "/Users/username/Documents/keys/mysshkey.pem" --generic-ssh-user ubuntuuser dockermachinename

上面的命令创建了docker-machine并且能够列出它

docker-machine ls

我可以通过运行SSH来连接它

docker-machine ssh dockermachinename

但当我尝试连接服务器(-D用于调试信息)

docker-machine -D env dockermachinename

我收到以下消息

Docker Machine Version: 0.5.2 ( 0456b9f )
Found binary path at /usr/local/bin/docker-machine-driver-generic
Launching plugin server for driver generic
Plugin server listening at address 127.0.0.1:54213
() Calling .GetVersion
Using API Version 1
() Calling .SetConfigRaw
() Calling .GetMachineName
(dockermachinename) Calling .GetState
(dockermachinename) Calling .GetURL
Reading CA certificate from /Users/username/.docker/machine/certs/ca.pem
Reading server certificate from /Users/username/.docker/machine/machines/dockermachinename/server.pem
Reading server key from /Users/username/.docker/machine/machines/dockermachinename/server-key.pem
Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "10.10.3.76:2376": dial tcp 10.10.3.76:2376: i/o timeout
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.

我真的需要解决这个问题,所有的帮助表示赞赏!

最佳答案 在Ubuntu上,您需要执行以下步骤:

1.创建不需要密码的用户

sudo visudo

在文件末尾添加以下行(确保指定您的用户名):

username    ALL=(ALL:ALL) NOPASSWD: ALL

然后保存并退出.之后,将您的用户名添加到这样的docker组(使用您的实际用户名更改用户名):

usermod -aG docker username

2.编辑docker config以打开2375和2376端口

sudo systemctl edit docker.service

将以下代码段添加到该文件:

[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2376 -H tcp://0.0.0.0:2375

然后保存并退出.之后重新加载配置并重启docker deamon:

sudo systemctl daemon-reload
sudo systemctl restart docker.service

3.创建docker-machine

删除失败的现有机器:

docker-machine rm machine1

并尝试再次创建它,如下所示:

docker-machine create -d generic --generic-ip-address ip --generic-ssh-key ~/.ssh/key --generic-ssh-user username --generic-ssh-port 22 machine1

请用你的实际值更改ip,key,username和machine1.

如果这产生如下错误:

Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "192.168.0.26:2376": tls: oversized record received with length 20527
You can attempt to regenerate them using 'docker-machine regenerate-certs [name]'.
Be advised that this will trigger a Docker daemon restart which might stop running containers.

然后SSH到你的机器并进入以下目录:

cd /etc/systemd/system/docker.service.d/

列出其中的所有文件:

ls -l

你可能会有这样的事情:

-rw-r--r--  1 root root  274 Jul  2 17:47 10-machine.conf
-rw-r--r--  1 root root  101 Jul  2 17:46 override.conf

你需要删除除了10-machine.conf之外的所有文件和sudo rm.

之后删除您创建的机器并再次创建它.它现在应该工作.我希望这有帮助.也许你已经步骤1和2,如果是这样,那么跳过它们,然后尝试删除override.conf文件或该目录中不是10-machine.conf的任何文件.

点赞