在B上执行以下命令,即可连接A的Docker服务:
docker --tlsverify --tlscacert=http://www.likecs.com/root/work/ca.pem --tlscert=http://www.likecs.com/root/work/cert.pem --tlskey=http://www.likecs.com/root/work/key.pem -H tcp://docker-daemon:2376 version控制台显示以下信息,其中Server部分就是A机器的Docker信息:
Client: Version: 1.13.1 API version: 1.26 Package version: docker-1.13.1-102.git7f2769b.el7.centos.x86_64 Go version: go1.10.3 Git commit: b2f74b2/1.13.1 Built: Wed May 1 14:55:20 2019 OS/Arch: linux/amd64 Server: Version: 1.13.1 API version: 1.26 (minimum version 1.12) Package version: docker-1.13.1-102.git7f2769b.el7.centos.x86_64 Go version: go1.10.3 Git commit: 7f2769b/1.13.1 Built: Mon Aug 5 15:09:42 2019 OS/Arch: linux/amd64 Experimental: false不用证书连接试试,各种尝试都失败了:
[root@centos7 work]# docker -H tcp://192.168.121.138:2375 images Cannot connect to the Docker daemon at tcp://192.168.121.138:2375. Is the docker daemon running? [root@centos7 work]# docker -H tcp://docker-daemon:2375 images Cannot connect to the Docker daemon at tcp://docker-daemon:2375. Is the docker daemon running? [root@centos7 work]# docker -H tcp://192.168.121.138:2376 images Get :2376/v1.26/images/json: net/http: HTTP/1.x transport connection broken: malformed HTTP response "\x15\x03\x01\x00\x02\x02". * Are you trying to connect to a TLS-enabled daemon without TLS? [root@centos7 work]# docker -H tcp://docker-daemon:2376 images Get :2376/v1.26/images/json: net/http: HTTP/1.x transport connection broken: malformed HTTP response "\x15\x03\x01\x00\x02\x02". * Are you trying to connect to a TLS-enabled daemon without TLS?至此,TLS加密远程连接Docker的实战就完成了,希望您在设置安全的Docker远程连接是,本文能给您提供参考。