离线安装docker,且开放tcp2375
0、环境
因某些环境,不能联外网,所以使用docker yum源方法行不通,于是打算离线安装。
环境:contos7.4(内核需为3.10+)
# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
下载地址:https://download.docker.com/linux/static/stable/x86_64/
1、安装
1)setup
cd /usr/local/resource/docker
tar -xf docker-18.06.3-ce.tar
mv /usr/local/resource/docker/docker/* /usr/bin/ # 将二进制文件移动到/user/bin,它是环境变量目录,在路径下都可以运行docker命令
2)systemd docker.service
vim /etc/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 -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
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
授予执行权限:
chmod +x /etc/systemd/system/docker.service
然后:
systemctl daemon-reload # 重载systemd下 xxx.service文件
systemctl start docker # 启动Docker
systemctl enable docker.service # 设置开机自启
测试是否成功:
systemctl status docker # 查看Docker状态
# docker -v # 查看Docker版本
Docker version 20.10.9, build c2ea9bc
3)开放tcp2375
因为编辑了vim /etc/systemd/system/docker.service的ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock,它默认开放了docker的2375,我们在浏览器输入http://IP:2375/version得到页面则表示我们配置一切正确
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 提示词工程——AI应用必不可少的技术
· 字符编码:从基础到乱码解决
· 地球OL攻略 —— 某应届生求职总结