diff --git a/docker-install.sh b/docker-install.sh old mode 100755 new mode 100644 index 52d70fa..171cb89 --- a/docker-install.sh +++ b/docker-install.sh @@ -1,16 +1,12 @@ # https://docs.docker.com/engine/install/debian/ -sudo apt-get update - -sudo apt-get install ca-certificates curl gnupg lsb-release -y - -read -p "Choose docker source (a: 阿里云, z: 中科大) >>" DOCKER_SOURCE +read -p "Choose docker source (a: 阿里云, z: 中科大) >> " DOCKER_SOURCE if [ $DOCKER_SOURCE = 'a' ] then GPG_URL=http://mirrors.aliyun.com/docker-ce/linux/debian/gpg DOCKER_URL=http://mirrors.aliyun.com/docker-ce/linux/debian COMPOSE_URL=https://get.daocloud.io/docker/compose/releases/download/1.29.2/ -elif [ $DOCKER_SOURCE = 'b' ] +elif [ $DOCKER_SOURCE = 'z' ] then GPG_URL=https://mirrors.ustc.edu.cn/docker-ce/linux/debian/gpg DOCKER_URL=https://mirrors.ustc.edu.cn/docker-ce/linux/debian @@ -21,6 +17,10 @@ else COMPOSE_URL=https://github.com/docker/compose/releases/download/1.29.2/ fi +echo Prepare environment ... +sudo apt-get update +sudo apt-get install ca-certificates curl gnupg lsb-release -y + echo Add Docker’s official GPG key ... sudo curl -fsSL $GPG_URL | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg @@ -34,3 +34,24 @@ sudo apt-get install docker-ce docker-ce-cli containerd.io -y echo Install Docker-Compose ... sudo curl -L $COMPOSE_URL/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose + +read -p "配置中国加速镜像源 /etc/docker/daemon.json (d: Docker中国, t: 腾讯云, z: 中科大) >> " DOCKER_MIRROR +if [ $DOCKER_MIRROR = 'd' ] +then + DOCKER_MIRROR=https://registry.docker-cn.com +elif [ $DOCKER_MIRROR = 't' ] +then + DOCKER_MIRROR=https://mirror.ccs.tencentyun.com +elif [ $DOCKER_MIRROR = 'z' ] +then + DOCKER_MIRROR=https://docker.mirrors.ustc.edu.cn +fi + +if [ $DOCKER_MIRROR ] +then + echo "{" | sudo tee /etc/docker/daemon.json > /dev/null + echo " \"registry-mirrors\": [" | sudo tee -a /etc/docker/daemon.json > /dev/null + echo " \"$DOCKER_MIRROR\"" | sudo tee -a /etc/docker/daemon.json > /dev/null + echo " ]" | sudo tee -a /etc/docker/daemon.json > /dev/null + echo "}" | sudo tee -a /etc/docker/daemon.json > /dev/null +fi \ No newline at end of file