CentOS7yum安装Docker20.10.11

一、安装脚本

mkdir -p /root/soft/jiaoben
vim /root/soft/jiaoben/yum_docker20-10-11.sh

点击查看代码
#!/bin/bash
# 定义颜色
BLUE_COLOR="\033[36m"
RED_COLOR="\033[31m"
GREEN_COLOR="\033[32m"
VIOLET_COLOR="\033[35m"
RES="\033[0m"


echo -e "${BLUE_COLOR}# ######################################################################${RES}"
echo -e "${BLUE_COLOR}#                       Docker  Install Script                       #${RES}"
echo -e "${BLUE_COLOR}# ######################################################################${RES}"

#安装依赖及工具包
yum install -y conntrack ntpdate ntp ipvsadm ipset  iptables curl sysstat libseccomp wget  vim net-tools git lrzsz

#设置防火墙
systemctl  stop firewalld  &&  systemctl  disable firewalld
yum -y install iptables-services  &&  systemctl  start iptables  &&  systemctl  enable iptables  &&  iptables -F  &&  service iptables save

#关闭selinux
setenforce 0 && sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config

# 设置系统时区为 中国/上海
timedatectl set-timezone Asia/Shanghai
# 将当前的 UTC 时间写入硬件时钟
timedatectl set-local-rtc 0

echo -e "${BLUE_COLOR}# ########################同步时钟################################${RES}"
#同步时钟
if  type ntpdate >/dev/null 2>&1; then
  ntpdate cn.pool.ntp.org 
else
  yum install -y ntpdate &&  ntpdate cn.pool.ntp.org 
fi

echo -e "${RED_COLOR}###########################开始时间:`date` #####################################${RES}"

# 检查docker
echo -e "${RED_COLOR}# ########################检查docker安装情况################################${RES}"
if   type docker >/dev/null 2>&1; then
    echo -e "docker已安装,检查通过!>>>>>>>>>>>>>>>>>>"
else
	yum install -y yum-utils device-mapper-persistent-data lvm2 gcc gcc-c++
	yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
	yum makecache fast
	mkdir -p /etc/docker
	echo '	{ ' >>  /etc/docker/daemon.json 
	echo '   "registry-mirrors": ["https://iq1ib072.mirror.aliyuncs.com"] , ' >>  /etc/docker/daemon.json 
	echo ' 	 "exec-opts":["native.cgroupdriver=systemd"],  ' >>  /etc/docker/daemon.json 
	echo ' 	 "live-restore": true ' >>  /etc/docker/daemon.json 
	echo ' 	}  ' >>  /etc/docker/daemon.json 
    yum install docker-ce-20.10.11 docker-ce-cli-20.10.11 containerd.io-1.4.12 -y 
    systemctl enable docker && systemctl start docker
	echo -e "${BLUE_COLOR}##############docker安装成功!#########################${RES}"
fi

echo -e "${RED_COLOR}###########################结束时间:`date` #####################################${RES}"

二、安装

sh /root/soft/jiaoben/yum_docker20-10-11.sh

三、验证

docker -v

posted @ 2023-04-20 15:20  村尚chun叔  阅读(73)  评论(0编辑  收藏  举报