#vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://cvpqlagp.mirror.aliyuncs.com"]
}
{"hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]}
# vim /usr/lib/systemd/docker.service
修改
ExecStart=
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
如下:
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network.target firewalld.service
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
ExecStart=
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
[Install]
WantedBy=multi-user.target
# systemctl daemon-reload
# systemctl restart docker
开放端口
# firewall-cmd --zone=public --add-port=2375/tcp --permanent
查看是否重启成功
[root@debug systemd]# docker version
Client:
Version: 17.03.0-ce
API version: 1.26
Go version: go1.7.5
Git commit: 3a232c8
Built: Tue Feb 28 08:10:07 2017
OS/Arch: linux/amd64
Server:
Version: 17.03.0-ce
API version: 1.26 (minimum version 1.12)
Go version: go1.7.5
Git commit: 3a232c8
Built: Tue Feb 28 08:10:07 2017
OS/Arch: linux/amd64
Experimental: false
查看监听的端口
[root@debug systemd]# netstat -tnlp
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:111 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 127.0.0.1:46160 0.0.0.0:* LISTEN 25663/java
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 25928/nginx: master
tcp 0 0 0.0.0.0:81 0.0.0.0:* LISTEN 25928/nginx: master
tcp 0 0 0.0.0.0:8082 0.0.0.0:* LISTEN 25663/java
tcp 0 0 0.0.0.0:8181 0.0.0.0:* LISTEN 11532/java
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 998/sshd
tcp 0 0 0.0.0.0:23000 0.0.0.0:* LISTEN 11318/fdfs_storaged
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 25928/nginx: master
tcp 0 0 0.0.0.0:8800 0.0.0.0:* LISTEN 4936/java
tcp 0 0 0.0.0.0:8801 0.0.0.0:* LISTEN 6708/java
tcp 0 0 127.0.0.1:8005 0.0.0.0:* LISTEN 4936/java
tcp 0 0 127.0.0.1:8006 0.0.0.0:* LISTEN 6708/java
tcp 0 0 0.0.0.0:8009 0.0.0.0:* LISTEN 4936/java
tcp 0 0 0.0.0.0:8010 0.0.0.0:* LISTEN 6708/java
tcp 0 0 0.0.0.0:22122 0.0.0.0:* LISTEN 11296/fdfs_trackerd
tcp6 0 0 :::111 :::* LISTEN 4450/rpcbind
tcp6 0 0 :::2375 :::* LISTEN 6444/dockerd