Centos8下docker自动化安装脚本

2022/4/16 7:17:07

本文主要是介绍Centos8下docker自动化安装脚本,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

vi yum.sh

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'
sed -i '$a\server cn.ntp.org.cn iburst'
systemctl restart chronyd.service

mv /etc/localtime{,.bak}

ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

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安装完成--------"

 



这篇关于Centos8下docker自动化安装脚本的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程