Centos8下docker自动化安装脚本
vi yum.sh
#! /bin/bash
echo "------- 时区配置--------"
sudo yum install -y chrony
systemctl start chronyd
sudo systemctl enable chronyd
sed -i 's/pool 2.centos.pool.ntp.org iburst/#&/' /etc/chrony.conf
sed -i '$a\server ntp.aliyun.com iburst' /etc/chrony.conf
sed -i '$a\server cn.ntp.org.cn iburst' /etc/chrony.conf
systemctl restart chronyd.service
chronyc sources -v
echo "------- 时区配置完成--------"
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
yum install -y yum-utils
yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
yum makecache fast
yum install docker-ce docker-ce-cli containerd.io -y
systemctl enable docker
systemctl start docker #注:如果你的服务器网段为172.17.0.0 服务器会连接断开,需要修改docker的默认网络为其他网段
cd /etc/docker/
touch "daemon.json"
sudo cat >>/etc/docker/daemon.json <<EOF
{
"registry-mirrors":["https://kn0t2bca.mirror.aliyuncs.com"],
"bip": ""
}
EOF
systemctl restart docker
echo "------- docker安装完成--------"
curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.5/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
#chmod +x /usr/local/bin/docker-compose
echo "------- docker-compose安装完成--------"