[root@jindada /scripts]$ cat docker_ins_apm.sh
#!/usr/bin/bash
# Author:jh
# Time:2021-04-21 11:54:22
# Name:docker_ins_apm.sh
# Version: 1.0
# Discription: To
rely_software=(yum-utils device-mapper-persistent-data lvm2)
#1.检测系统内核版本
source /etc/init.d/functions
kernel_version=`uname -a |awk '{print $3}'|cut -d. -f1`
if [ $kernel_version -ge 3 ];then
echo 'The System Can Install docker;'
else
echo 'The System Can not Install docker;';exit
fi
#2.安装依赖软件
for i in ${rely_software[*]}
do
rpm -q $i &>/dev/null
if [ $? -eq 0 ];then
echo "$i is installed"
else
yum -y install $i &>/dev/null
action "$i is installing" /usr/bin/true
fi
done
#3.添加docker镜像源
yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
if [ $? -eq 0 ];then
echo "Docker Image added;"
else
echo "Docker Image add failed"
fi
#4.安装docker
yum install docker-ce -y
#5.启动docker并设置开机自启
systemctl enable --now docker
if [ $? -eq 0 ];then
echo "Docker started;"
else
echo "Docker start failed"
fi
#6.验证服务
docker_version=`docker -v`
echo $docker_version
#7.设置加速器
sudo mkdir -p /etc/docker
sudo cat >/etc/docker/daemon.json <<EOF
{
"registry-mirrors": ["https://8mh75mhz.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
#8.docker安装完成提示语
cat << EOF
+-------------------------------------------------+
| docker 安 装 已 完 成 |
| 请 使 用 相 关 服 务 ! |
+-------------------------------------------------+
EOF
sleep 5