Linux - Docker install

2021/6/9 7:21:51

本文主要是介绍Linux - Docker install,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

#####################

# install docker

#####################
installDocker(){

if [[ ${OS_VERSION} = "centos" ]];then

COLOR="echo -e \\033[1;31m"
END="\033[m"
VERSION="19.03.5-3.EL7"

rm -rf /etc/yum.repos.d/*

wget -P /etc/yum.repos.d/ https://mirrors.aliyun.com/repo/Centos-7.repo || { ${COLOR}"BaseOS:Can't access the internet,please check your connection!"${END};exit;}

wget -P /etc/yum.repos.d/ https://mirrors.aliyun.com/repo/epel-7.repo || { ${COLOR}"Epel:Can't access the internet,please check your connection!"${END};exit;}

wget -P /etc/yum.repos.d/ https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo || { ${COLOR}"Docker-ce:Can't access the internet,please check your connection!"${END};exit;}



yum clean all

yum -y install docker-ce || { ${COLOR}"Base,Extras yum sources is unavailable, please check yum sources"${END};exit;}

mkdir -p /etc/docker
cat > /etc/docker/daemon.json <<EOF
{
"registry-mirrors": ["https://u5qp98hs.mirror.aliyuncs.com"]
}
EOF

systemctl enable --now docker
docker version && ${COLOR}"Docker install succesfully"${END} || ${COLOR}"Docker install failed"${END}

else

# ubuntu

apt update
apt -y install apt-transport-https ca-certificates curl software-properties-common

curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | apt-key add -

add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
apt -y update
apt -y install docker-ce

systemctl enable --now docker
docker version && ${COLOR}"Docker install succesfully"${END} || ${COLOR}"Docker install failed"${END}
fi
reboot

}

 



这篇关于Linux - Docker install的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程