tar -zxvf docker-20.10.20.tgz
mv docker/* /usr/bin/
echo "
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target" > /etc/systemd/system/docker.service
chmod +x /etc/systemd/system/docker.service
systemctl daemon-reload
systemctl enable docker.service
systemctl start docker
以上为网上参考
下边为项目中的
#!/bin/bash
set -x
#set -e
function stop_docker() {
docker_is_running=`systemctl list-units|grep docker.service|wc -l`
if [ "$docker_is_running" != "" ] && [ "$docker_is_running" -eq 1 ]; then
systemctl stop docker
systemctl disable docker
fi
status=`systemctl is-active docker`
if [ "$status" != "" ] && [ "$status" = "active" ]; then
systemctl stop docker
systemctl disable docker
fi
}
if [ -f "/etc/.kyinfo" ]; then
version=`cat /etc/.kyinfo | grep milestone | awk -F= '{print $2}'`
if [ "$version" != "" ] && [ "$version" = "4.0.2-server-sp2-18011911.J1" ]; then
if [ ! -f "/usr/bin/docker" ]; then
echo -e "\033[35m[docker is not exist]\033[0m"
else
docker_version=`docker info|grep "Server Version"|cut -d ':' -f 2 |sed -e 's/^[ ]*//g'`
if [ "$docker_version" != "" ] && [ "$docker_version" = "1.12.6" ]; then
echo -e "\033[35m[uninstall docker 1.12.6]\033[0m"
stop_docker
echo $?
apt list|grep docker |awk -F'/' '{print $1}'|grep docker.io
apt --purge remove docker.io
if [ -f "/usr/sbin/runc" ]; then
mv -v /usr/sbin/runc /usr/sbin/runc.bak
fi
#/usr/sbin/run_init
fi
fi
fi
fi
stop_docker
echo $?
if [ -f /etc/systemd/system/multi-user.target.wants/docker.service ]; then
rm -fv /etc/systemd/system/multi-user.target.wants/docker.service
fi
echo '解压tar包'
tar zxvf docker-23.0.6-aarch64.tgz
echo '将docker目录移到/usr/bin目录下...'
cp -v docker/* /usr/bin/
echo '将docker.service移到/etc/systemd/system/ 目录...'
if [ ! -d /etc/docker ]; then
echo "docker 目录不存在"
mkdir -p /etc/docker
fi
cp daemon.json /etc/docker/daemon.json
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安装成功...'
echo '安装docker-compose'
cp -v docker-compose /usr/bin/
chmod +x /usr/bin/docker-compose
docker -v && docker-compose -v
rm -frv docker/*