系统: centos 7

Docker version 1.12.6

yum 安装的  #yum install docker

docker server在192.168.111.120上

# vim /lib/systemd/system/docker.service

在 ExecStart 最后追加   -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock

如:

ExecStart=/usr/bin/dockerd-current \
--add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \
--default-runtime=docker-runc \
--exec-opt native.cgroupdriver=systemd \
--userland-proxy-path=/usr/libexec/docker/docker-proxy-current \
$OPTIONS \
$DOCKER_STORAGE_OPTIONS \
$DOCKER_NETWORK_OPTIONS \
$ADD_REGISTRY \
$BLOCK_REGISTRY \
$INSECURE_REGISTRY \
-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock

#systemctl daemon-reload

#systemctl restart docker

测试:

在另一台机器(192.168.111.111)上:

#docker -H tcp://192.168.111.120:2375 info

docker -H 192.168.111.120:2375 info

或 设置环境变量:export DOCKER_HOST=192.168.111.120:2375

# docker info

04-19 12:21