[root@CenOS-1 system]# systemctl disable docker
rm -rf /etc/systemd/system/docker.service
rm -rf $(find / -name docker)
install-docker.sh
#!/bin/sh
CURRENT_PATH=$(pwd)
DOCKER_TGZ=docker-20.10.9.tgz
chattr -i /etc/group
chattr -i /etc/gshadow
chattr -i /etc/passwd
chattr -i /etc/shadow
function exit_script(){
exit 1
}
function operate(){
systemctl enable docker
docker -v
}
var=$(uname -r)
temp=${var:0:4}
a=$(echo $temp)
b=3.10
a1=${a:0:1}
a2=${a:2:1}
a3=${a:3:1}
b1=${b:0:1}
b2=${b:2:1}
b3=${b:3:1}
temp1=`expr $a1 \* 100 - $b1 \* 100 + $a2 \* 10 - $b2 \* 10 + $a3 - $b3`
#echo $temp1
echo -e "\033[35m ++++++++ current docker version $a ++++++++ \033[0m"
if [ $temp1 -ge 0 ]
then
echo -e "\033[35m ++++++++ Can be installed docker ++++++++ \033[0m"
else
echo -e "\033[35m As the version is too low, docker requires at least 3.10 or more kernel versions to install, so docker cannot be installed temporarily \033[0m"
exit_script
fi
echo -e "\033[35m ++++++++ Start installing Docker ++++++++ \033[0m"
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
rm -rf /var/lib/docker
echo -e "\033[35m ++++++++ Start install -$DOCKER_TGZ ,please waiting... ++++++++ \033[0m"
tar -xvf $CURRENT_PATH/docker/$DOCKER_TGZ -C docker
cp $CURRENT_PATH/docker/docker/* /usr/bin/
tee /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 +x /etc/systemd/system/docker.service
systemctl daemon-reload
systemctl start docker
echo -e "\033[35m ++++++++ Install success ++++++++ \033[0m"
operate
echo -e "\033[35m ++++++++ docker restart and join the boot ++++++++ \033[0m"
cd $CURRENT_PATH
install-docker-compose.sh
#!/bin/sh
CURRENT_PATH=$(pwd)
DC_NAME='docker-compose-Linux-x86_64'
echo 'Start install docker-compose ...'
mv $CURRENT_PATH/docker/$DC_NAME /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
echo 'Install docker-compose suceess'
docker-compose -v