#!/bin/bash
#Author:haodong
#Date:2022-3-31
#Func:quickly install docker-19.03.3.tar.gz
#set -e
set -x
clear
. /etc/init.d/functions
function check_network (){
local timeout=1
local target=www.baidu.com
local return_code=$(curl -I -s --connect-timeout ${timeout} ${target} -w %{http_code} | tail -n1)
if [ "x$return_code" = "x200" ];then
action "Check Netwrok pass" /bin/true
else
action "Check Network failed" /bin/failed
exit 1
fi
}
function install_docker (){
if rpm -q wget &>/dev/null;then
wget https://download.docker.com/linux/static/stable/x86_64/docker-19.03.3.tgz -P /opt &>/dev/null
else
yum -y install wget &> /dev/null && \
wget https://download.docker.com/linux/static/stable/x86_64/docker-19.03.3.tgz -P /opt &>/dev/null
fi
tar -xf /opt/docker-19.03.3.tgz -C /opt && cp -rf /opt/docker/* /usr/bin
cat > /usr/lib/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
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP
LimitNOFILE=infinity
LimitNPROC=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=yes
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
EOF
systemctl restart docker && systemctl enable docker &>/dev/null
local docker_status=$(systemctl is-active docker)
if [[ ${docker_status} == "active" ]];then
action "Docker-19.03.3 is Installed" /bin/true
elif which docker &>/dev/null;then
action "Docker-19.03.3 is Installed" /bin/true
else
action "Docker daemon service start fail" /bin/false
exit
fi
}
check_network
install_docker
shell脚本之二进制安装docker
最新推荐文章于 2023-07-13 11:25:38 发布