基于Ubuntu-1804, 以及阿里云镜像站
Docker版本19.03.12
#!/bin/bash
COLOR="echo -e \033[1;31m"
END="\033[0m"
DOCKER_VERSION="5:19.03.12~3-0~ubuntu-bionic"
install_docker(){
dpkg -s docker-ce &> /dev/null && ${COLOR}"Docker已安装, 退出"${END} && exit
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 | sudo apt-key add -
add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
apt update
${COLOR}"5秒后即将安装: docker-"${DOCKER_VERSION}"版本......"${END}
${COLOR}"如果想安装其他版本Docker, 请按ctrl+c键退出, 修改版本再执行"${END}
sleep 5
apt -y install docker-ce=${DOCKER_VERSION} docker-ce-cli=${DOCKER_VERSION}
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-EOF
{
"registry-mirrors": ["https://自动的aliyun加速.mirror.aliyuncs.com"]
}
EOF
systemctl daemon-reload
systemctl enable --now docker
docker version && ${COLOR}"Docker 安装成功"${END} || ${COLOR}"Docker 安装失败"${END}
}
install_docker
网友评论