修改docker配置使其支持本机tcp连接
/lib/systemd/system/docker.service 内容如下[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target[Service]
Type=notify
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-storage
EnvironmentFile=-/etc/sysconfig/docker-network
Environment=GOTRACEBACK=crash
ExecStart=/usr/bin/dockerd $OPTIONS \$DOCKER_STORAGE_OPTIONS \$DOCKER_NETWORK_OPTIONS \$INSECURE_REGISTRY
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
# 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
修改 OPTIONS
vi /etc/sysconfig/docker原来的内容
# /etc/sysconfig/docker# Modify these options if you want to change the way the docker daemon runs
OPTIONS='--live-restore'DOCKER_CERT_PATH=/etc/docker
修改后
# /etc/sysconfig/docker# Modify these options if you want to change the way the docker daemon runs
OPTIONS='-H unix:///var/run/docker.sock -H tcp://127.0.0.1:2375 --live-restore'DOCKER_CERT_PATH=/etc/docker
顺序不能错,–live-restore 放到最后
重启生效
sudo systemctl daemon-reload
sudo systemctl restart docker
验证生效
netstat -tulnp | grep 2375