CentOS 7 下 脚本安装 Docker Engine

这学期给学生讲授Docker方面的知识,带着学生做相关项目,发现有学生在部署操作系统和Docker时频繁报错,Linux命令行工具都忘记使用方法了,为了不耽误项目操作进度,特意给学生写了个shell脚本,用来进行操作系统的初始化配置及Docker安装。

脚本内容如下:

#!/bin/sh
echo "################ README INFO ############################"

echo "### Purpose: initial CentOS 7 & install Docker Engine ###"

echo "### Made By: PomanTeng                                ###"

echo "### E-mail: [email protected]                  ###"

echo "### WeChat: 1807479153                                ###"

echo "### Version Identification Number:V0.00               ###"

echo "### Procedure Identification Number:20210911          ###"

echo "#########################################################"
echo "***** OS环境初始化 *****"
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.original
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
rm -rf /var/run/yum.pid
yum clean all
rm -rf /var/run/yum.pid
yum makecache
rm -rf /var/run/yum.pid
yum -y update
rm -rf /var/run/yum.pid
systemctl stop firewalld && systemctl disable firewalld
sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config && setenforce 0
wget https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
sed -i 's|^#baseurl=https://download.fedoraproject.org/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
yum clean all && yum makecache
yum -y update
yum install -y ntpdate
ntpdate cn.ntp.org.cn
yum install -y tree
echo "***** 安装 Docker Engine *****"
yum remove -y docker*
chkconfig --del docker
rm -rf /var/run/yum.pid
yum -y update
rm -rf /var/run/yum.pid
hostnamectl set-hostname Dcoker-single
rm -rf /var/run/yum.pid
yum install -y -q yum-utils device-mapper-persistent-data lvm2
rm -rf /var/run/yum.pid
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
rm -rf /var/run/yum.pid
yum clean all && yum makecache
rm -rf /var/run/yum.pid
yum install -y -q docker-ce
rm -rf /var/run/yum.pid
systemctl start docker
systemctl enable docker
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://registry.docker-cn.com"]
}
EOF
systemctl daemon-reload
systemctl restart docker
systemctl status docker

init 6

你可能感兴趣的:(docker,centos,linux)