在centos7上配置docker daemon的遠端通路
檢視幫助文檔可以看到docker支援三種方式的通信,unix,tcp,fd
-H, –host=[unix:///var/run/docker.sock]: tcp://[host]:[port][path] to bind or unix://[/path/to/socket] to use.
The socket(s) to bind to in daemon mode specified using one or more
tcp://host:port/path, unix:///path/to/socket, fd://* or fd://socketfd.
If the tcp port is not specified, then it will default to either 2375 when
–tls is off, or 2376 when –tls is on, or –tlsverify is specified.
daemon指令來操作docker的守護程序,用-H 指令決定監聽的對象,可同時監聽多個,例如:
dockerd -H unix:///var/run/docker.sock -H tcp://192.168.59.106 -H tcp://10.10.10.2
也可以修改配置檔案
在/etc/docker/daemon.json 中加入鍵值對
{
"hosts":["192.168.199.106","unix:///var/run/docker.sock"]
}
重新開機docker
systemctl restart docker
此時可以通過遠端client操作docker
docker -H 192.168.199.106 info
注意docker此處可能有漏洞,Docker本身提供了加密的遠端管理端口2376,配合CA憑證,就能提供TLS連接配接了。
配置docker安全可以參考 http://www.sohu.com/a/76802346_355135