centos7 离线(内网环境无外网) 安装docker

1. 环境

1. centos 7 内网环境 无外网连接,yum安装会失效,采用离线安装包方式安装docker

 

2. 下载安装包

1. 百度网盘:

链接:https://pan.baidu.com/s/1ArPt-NhjtdKTBW3I4BE-iQ
提取码:ngyh

2. 采用的是docker-19.03.9 这个版本

 

3. 安装脚本

#!/bin/sh
#author 明知山有小脑斧<12345ssdlh.xyz>
#describe docker安装脚本

# 解压docker文件
tar -zxvf docker-19.03.9.tgz

# 将docker目录移到/usr/bin目录下...
mv docker/* /usr/bin/

# 写入docker 配置文件
cat >> /etc/systemd/system/docker.service << EOF
[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
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
EOF

# 添加文件权限
chmod 755 /etc/systemd/system/docker.service

# 重新加载配置文件
systemctl daemon-reload

# 启动docker
systemctl start docker

# 设置开机自启动
systemctl enable docker.service

# 删除docker 解压文件
rm -rf ./docker

sleep 1
clear

把安装脚本复制到安装包同一路径下,保存为docker.sh 文件

赋予docker.sh 执行权限

chmod 755 docker.sh

 

4. 安装

执行docker安装命令

sh docker.sh

等待安装完成

 

5. 测试安装

docker ps -a
docker info 
docker -v
docker images

上述命令挨个执行一遍,看看控制台是否有输出,有输出证明安装成功

 

6. 捐赠支持

你可以请作者喝杯咖啡表示鼓励

 

posted @ 2022-12-05 15:47  明知山有小脑斧  阅读(1330)  评论(0编辑  收藏  举报