随着CentOS全面停服,国产操作系统会慢慢代替centos系统,在后续的项目中,项目部署的环境都必将是国产操作系统,本文就国产操作系统下如何离线安装docker,做下笔记分享
一、材料准备
1、国产操作系统 麒麟10,arm64v8
2、dokcer部署包(版本:docker-18.09.tgz)
3、部署docker脚本(docker.service),已经启动命令脚本(install.sh)
二、编写docker.service脚本
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
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
三、编写启动install.sh脚本
#!/bin/sh
#
# 说明:离线安装 docker
# 日期:2024-08-19
# 作者:yyxf
echo '解压tar包...'
tar -xvf docker-18.09.tgz
echo '将docker目录移动/usr/bin目录下...'
cp -p docker/* /usr/bin/
rm -rf docker/
echo '添加docker-compose文件权限'
chmod +x /usr/local/bin/docker-compose
echo '将docker.service 移到/etc/systemd/system/ 目录...'
cp docker.service /etc/systemd/system/
echo '添加文件权限...'
chmod +x /etc/systemd/system/docker.service
echo '重新加载配置文件...'
systemctl daemon-reload
echo '启动docker...'
systemctl start docker
echo '设置开机自启...'
systemctl enable docker.service
echo 'docker安装成功...'
docker -v
四、执行命令并验证
至此已经简单的docker环境已经部署完成
docker部署包以及相关脚本,请参考如下地址
麒麟操作系统离线安装docker环境所需的部署包以及相关脚本资源-CSDN文库