Docker 打开 TCP 端口
原文链接:https://www.lucien.ink/archives/440/
1. 开启 TCP 端口
1.1 创建目录/文件
mkdir -p /etc/systemd/system/docker.service.d
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
1.2 重启 docker 进程
systemctl daemon-reload
systemctl restart docker
1.4 查看端口是否打开
ps aux | grep dockerd | grep -v grep
2. 关闭 TCP 端口
rm -f /etc/systemd/system/docker.service.d/tcp.conf
systemctl daemon-reload
systemctl restart docker
ps aux | grep dockerd | grep -v grep