Centos7中docker开启远程访问
在作为docker远程服务的centos7机器中配置:
1、在/usr/lib/systemd/system/docker.service,配置远程访问。主要是在[Service]这个部分,加上下面两个参数
# vim /usr/lib/systemd/system/docker.service [Service] ExecStart= ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
2、docker重新读取配置文件,重新启动docker服务
# systemctl daemon-reload
# systemctl restart docker
3、查看docker进程,发现docker守护进程在已经监听2375的tcp端口
# ps -ef|grep docker root 26208 1 0 23:51 ? 00:00:00 /usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
4、查看系统的网络端口,发现tcp的2375端口,的确是docker的守护进程在监听
# netstat -tulp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN 886/sshd tcp6 0 0 [::]:2375 [::]:* LISTEN 26208/dockerd
5、这里拿本地的ubuntu做客户端,来访问阿里云上centos7的docker服务,访问成功。139.129.130.123是阿里云上的centos7机器公网ip。
$ sudo docker -H tcp://139.129.130.123:2375 images REPOSITORY TAG IMAGE ID CREATED SIZE mysql 5.6 f8fe303bcac2 4 days ago 298MB
6、浏览器访问地址
http://139.129.130.123:2375/info
http://192.168.128.162:2375/v1.38/images/json?filters={"reference":{"mysql":true}}
posted on 2018-08-31 14:49 clearriver 阅读(4139) 评论(0) 编辑 收藏 举报