第一步,新建docker-tcp.socket
vi /etc/systemd/system/docker-tcp.socket
第二步,編輯內容
[Unit]
Description=Docker Socket for the API
[Socket]
ListenStream=2375
BindIPv6Only=both
Service=docker.service
[Install]
WantedBy=sockets.target
第三步,開啟服務
systemctl enable docker-tcp.socket(設置開機啟動)
systemctl stop docker
systemctl start docker-tcp.socket
systemctl start docker
最后測試一下
docker -H tcp://127.0.0.1:2375 ps