加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
1_run_docker.sh 2.46 KB
一键复制 编辑 原始数据 按行查看 历史
GuoPeng 提交于 2021-11-29 07:28 . sell
#!/bin/bash
printf "==============》》开始搭建基础环境《《==============\n"
printf "1.开始关闭防火墙\n"
systemctl stop firewalld
systemctl disable firewalld
printf "防火墙已关闭\n"
printf "2.开始关闭 SeLinux\n"
setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
printf "3.关闭swap交换区\n"
swapoff -a
yes | cp /etc/fstab /etc/fstab_bak
cat /etc/fstab_bak |grep -v swap > /etc/fstab
printf "4.开始安装yum并替换阿里云eoel源\n"
# 安装wget
yum install wget -y
# 备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
# 获取阿里云yum源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# 获取阿里云epel源
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
# 清理缓存并创建新的缓存
yum clean all && yum makecache
# 系统更新
yum update -y
printf "5.同步时区,上海时区\n"
timedatectl set-timezone "Asia/Shanghai"
timedatectl
printf "\n"
# 安装 Docker CE
# 设置仓库
# 安装所需包
printf "6.开始安装docker需要的依赖\n"
yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
# 新增 Docker 仓库,速度慢的可以换阿里云的源。
printf "7.新增 Docker 仓库,替换换阿里云的源\n"
yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 官方源地址
# https://download.docker.com/linux/centos/docker-ce.repo
# 安装 Docker CE.
printf "8.安装 Docker CE\n"
yum install -y containerd.io-1.2.10 \
docker-ce-19.03.4 \
docker-ce-cli-19.03.4
# 启动 Docker 并添加开机启动
printf "9.启动 Docker 并添加开机启动\n"
systemctl start docker
systemctl enable docker
printf "10.修改 Cgroup Driver\n"
cat > /etc/docker/daemon.json <<EOF
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2",
"registry-mirrors":[
"https://kfwkfulq.mirror.aliyuncs.com",
"https://2lqq34jg.mirror.aliyuncs.com",
"https://pee6w651.mirror.aliyuncs.com",
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn",
"https://registry.docker-cn.com"
]
}
EOF
docker info|grep "Cgroup Driver"
mkdir -p /etc/systemd/system/docker.service.d
printf "11.重启docker\n"
# Restart docker.
systemctl daemon-reload
systemctl restart docker
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化