当前位置: 首页 > news >正文

docker 开启 tcp 端口

前言:查了很多网上资料  都说要修改daemons,json  完全不管用,而且还导致添加

{“host”:["tcp://0.0.0.0:2375","unix:///var/lib/docker.sock"]}

后,docker restart 失败,浪费了不少时间 !!!

下边的方式是测试没问题的,记录分享一下。

默认安装的Docker服务是不支持远程连接的,开启TCP端口后可以进行远程连接Docker

1、操作系统环境:ubuntu 18.4

2、编辑 docker 服务

注释原有 ExecStart 参数,新增 ExecStart 参数,见加红色字体。

注意是在“/lib/systemd/system/”目录下,网上很多人路径是“/usr/lib/systemd/”进去你会发现并没有system目录何况docker.service了

[root@localhost home]# vi /lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target

[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
ExecStart=/usr/bin/dockerd -H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375

ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s

[Install]
WantedBy=multi-user.target

-H代表指定docker的监听方式,这里是socket文件位置,也就是socket方式,2375就是tcp端口

 

3、保存退出

4、重新加载系统服务配置文件

systemctl daemon-reload

5、重启 docker 服务

systemctl restart docker

 

6、查看监听端口

netstat -nplt | grep 2375

http://www.lryc.cn/news/344886.html

相关文章:

  • zookeeper之分布式环境搭建
  • java设计模式三
  • ##12 深入了解正则化与超参数调优:提升神经网络性能的关键策略
  • TODESK怎么查看有人在远程访问
  • 【Web漏洞指南】服务器端 XSS(动态 PDF)
  • Qt中的对象树
  • QT-day1
  • 安装oh-my-zsh(命令行工具)
  • 解决方案:‘Series‘ object has no attribute ‘xxxx‘
  • 智慧手术室手麻系统源码,C#手术麻醉临床信息系统源码,符合三级甲等医院评审要求
  • 项目公共组件代码
  • 深入解析MySQL中的事务(上)
  • Springboot项目使用redis实现session共享
  • 【Linux】Centos7安装部署unimrcp,搭建MRCP服务器
  • 什么是Jetpack
  • macOS sonoma 14.4.1编译JDK 12
  • GPU通用计算介绍
  • 如果数据给的是树形 转好的树形结构并且是有两个二级children的话 该如何写?
  • C++ 函数重载
  • 5. 分布式链路追踪TracingFilter改造增强设计
  • C++数据类型与表达式
  • 电脑ip地址设置成什么比较好
  • vue-element-template优化升级dart-sass、pnpm
  • Oracle拼接json字符串
  • 如何向Linux内核提交开源补丁?
  • python数据分析——pandas DataFrame基础知识2
  • TODESK远程开机的原理
  • 【c1】数据类型,运算符/循环,数组/指针,结构体,main参数,static/extern,typedef
  • word图片水印
  • kali安装及替换源