Centos7中docker开启远程访问(Centos7 docker remote access configure)
1、在/usr/lib/systemd/system/docker.service,配置远程访问。主要是在[Service]这个部分,加上下面两个参数
# vi /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服务
启动docker:systemctl start docker
停止docker:systemctl stop docker
重启docker: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