docker客户端
export DOCKER_HOST=tcp://127.0.0.1:2375
docker服务器
cat > /etc/systemd/system/docker.service.d/tcp.conf <<EOF
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375
EOF
重启docker服务及daemon服务
systemctl daemon-reload
systemctl restart docker
检测端口是否开启
ps aux |grep dockerd
或者
netstat -an | grep 2375
CentOS6还可以通过修改/etc/sysconfig/docker文件中的 other_args来达到同样的目的
other_args='-Htcp://0.0.0.0:2375 -H unix:///var/run/docker.sock'
或
other_args='--selinux-enabled -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375'
CentOS7还可以通过修改/etc/sysconfig/docker文件中的 OPTIONS来达到同样的目的
OPTIONS='-Htcp://0.0.0.0:2375 -H unix:///var/run/docker.sock'
或
OPTIONS='--selinux-enabled -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375'
关闭TCP管理端口
rm /etc/systemd/system/docker.service.d/tcp.conf -rf
systemctl daemon-reload
systemctl restart docker
ps aux |grep dockerd
docker进入容器命令行
#docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
71a419b6035f openstf/stf "stf local --public-…" 20 minutes ago Up 20 minutes stf
ad99acebfae9 sorccu/adb:latest "/sbin/tini -- adb -…" 23 minutes ago Up 23 minutes adbd
a6281854997d rethinkdb "rethinkdb --bind al…" 23 minutes ago Up 23 minutes rethinkdb
#docker exec -it 71a419b6035f sh
$ ls
CHANGELOG.md DONATION-TRANSPARENCY.md LICENSE TESTING.md doc node_modules res yarn.lock
CONTRIBUTING.md ISSUE_TEMPLATE.md README.md bin lib package.json vendor
$