前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Docker 开启2375端口提供外部访问

Docker 开启2375端口提供外部访问

作者头像
全栈程序员站长
发布2022-08-25 09:42:01
2K0
发布2022-08-25 09:42:01
举报
文章被收录于专栏:全栈程序员必看

大家好,又见面了,我是你们的朋友全栈君。

Docker 开启2375端口提供外部访问
Docker 开启2375端口提供外部访问

1、编辑docker.service

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

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

代码语言:javascript
复制
-H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
代码语言:javascript
复制
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket containerd.service

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H tcp://0.0.0.
0:2375 -H unix://var/run/docker.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3

# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s

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

# systemctl daemon-reload

# systemctl restart docker

代码语言:javascript
复制
[root@docker-servers ~]# systemctl daemon-reload
[root@docker-servers ~]# systemctl restart docker
[root@docker-servers ~]# netstat -tunlp | grep 2375
tcp6       0      0 :::2375                 :::*                    LISTEN      96681/dockerd

3、开放防火墙端口

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

代码语言:javascript
复制
[root@localhost ~]# firewall-cmd --zone=public --add-port=2375/tcp --permanent
success

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

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/142095.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022年5月9,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 1、编辑docker.service
  • 2、重启docker,重新读取配置文件,重新启动docker服务
  • 3、开放防火墙端口
相关产品与服务
容器镜像服务
容器镜像服务(Tencent Container Registry,TCR)为您提供安全独享、高性能的容器镜像托管分发服务。您可同时在全球多个地域创建独享实例,以实现容器镜像的就近拉取,降低拉取时间,节约带宽成本。TCR 提供细颗粒度的权限管理及访问控制,保障您的数据安全。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档