如何使docker客户端通过http连接到docker守护进程

时间:2016-12-14 14:12:40

标签: http docker docker-machine

我有一个运行docker守护程序的主机有这些选项:

dockerd -H tcp://0.0.0.0:2376 ...

从远程主机我想用docker-machine连接到这个实例的docker API,但我总是收到以下消息:

http: server gave HTTP response to HTTPS client

我的主持人在http:

上做出了很好的回应
root$ curl -v  http://10.228.38.30:2376/v1.15/version
* Hostname was NOT found in DNS cache
*   Trying 10.228.38.30...
* Connected to 10.228.38.30 (10.228.38.30) port 2376 (#0)
> GET /v1.15/version HTTP/1.1
> User-Agent: curl/7.38.0
> Host: 10.228.38.30:2376
> Accept: */*
> 
< HTTP/1.1 200 OK
< Content-Type: application/json
* Server Docker/1.12.3 (linux) is not blacklisted
< Server: Docker/1.12.3 (linux)
< Date: Wed, 14 Dec 2016 12:25:45 GMT
< Content-Length: 196
< 
{"Version":"1.12.3","ApiVersion":"1.24","GitCommit":"6b644ec","GoVersion":"go1.6.3","Os":"linux","Arch":"amd64","KernelVersion":"3.16.0-4-amd64","BuildTime":"2016-10-26T21:39:14.007365648+00:00"}
* Connection #0 to host 10.228.38.30 left intact

如何告诉docker客户端(即这里的docker-machine)通过http而不是https与守护进程通信?

我不需要https,因为我在测试环境中。

1 个答案:

答案 0 :(得分:0)

首先,您需要configure your Docker daemon才能使用HTTP而不是HTTPS。

然后你可以添加一个generic driver的泊坞机,如下所示:

$ docker-machine create \
  --driver generic \
  --generic-ip-address=203.0.113.81 \
  --generic-ssh-key ~/.ssh/id_rsa \
  vm