当前位置:   article > 正文

Docker 开启2375端口提供外部访问_-h 0.0.0.0:2375

-h 0.0.0.0:2375

1、编辑docker.service

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

在 ExecStart=/usr/bin/dockerd-current 后 增加

-H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
  1. [Unit]
  2. Description=Docker Application Container Engine
  3. Documentation=https://docs.docker.com
  4. After=network-online.target firewalld.service containerd.service
  5. Wants=network-online.target
  6. Requires=docker.socket containerd.service
  7. [Service]
  8. Type=notify
  9. # the default is not to use systemd for cgroups because the delegate issues still
  10. # exists and systemd currently does not support the cgroup feature set required
  11. # for containers run by docker
  12. ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H tcp://0.0.0.
  13. 0:2375 -H unix://var/run/docker.sock
  14. ExecReload=/bin/kill -s HUP $MAINPID
  15. TimeoutSec=0
  16. RestartSec=2
  17. Restart=always
  18. # Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
  19. # Both the old, and new location are accepted by systemd 229 and up, so using the old location
  20. # to make them work for either version of systemd.
  21. StartLimitBurst=3
  22. # Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
  23. # Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
  24. # this option work for either version of systemd.
  25. StartLimitInterval=60s

2、重启docker,重新读取配置文件,重新启动docker服务

# systemctl daemon-reload

# systemctl restart docker

  1. [root@docker-servers ~]# systemctl daemon-reload
  2. [root@docker-servers ~]# systemctl restart docker
  3. [root@docker-servers ~]# netstat -tunlp | grep 2375
  4. tcp6 0 0 :::2375 :::* LISTEN 96681/dockerd

3、开放防火墙端口

# firewall-cmd --zone=public --add-port=2375/tcp --permanent

  1. [root@localhost ~]# firewall-cmd --zone=public --add-port=2375/tcp --permanent
  2. success

如果您使用的是云服务器,您还需要打开对应的云服务器安全组,在安全组里面配置对应的端口才行。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/575957
推荐阅读
相关标签
  

闽ICP备14008679号