最近在学习kubernetes的架设,自然就需要安装很多Docker,但是安装操作系统、修改仓库、安装Docker这一路下来步骤太多,自己就用三脚猫功夫写了个脚本,脚本其实挺强大,我这入门的水平都可以写出可实际使用的效果。
因为技术比较入门,所以步骤非常繁琐,但实测确实有效。

Centos 安装docker

# 安装依赖包
yum install -y yum-utils device-mapper-persistent-data lvm2

# 安装aliyun repo
yum-config-manager \
  --add-repo \
  https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

# 安装docker-ce
yum install -y docker-ce

Debian 9 国内环境下一键脚本安装Docker

#!/bin/bash
cat >/etc/apt/sources.list <<EOF
deb http://mirrors.163.com/debian/ stretch main non-free contrib
deb http://mirrors.163.com/debian/ stretch-updates main non-free contrib
deb http://mirrors.163.com/debian/ stretch-backports main non-free contrib
deb-src http://mirrors.163.com/debian/ stretch main non-free contrib
deb-src http://mirrors.163.com/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.163.com/debian/ stretch-backports main non-free contrib
deb http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib
deb-src http://mirrors.163.com/debian-security/ stretch/updates main non-free contrib
EOF
apt update
apt install -y  apt-transport-https ca-certificates curl gnupg2 software-properties-common
curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/debian/gpg | apt-key add -
echo "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/debian stretch stable" >>/etc/apt/sources.list
apt update
apt install -y docker-ce
systemctl start docker
systemctl enable docker

就像上一篇文章一样,如果Docker.com没有被墙的话,一行shell就可以搞定。

Last modification:May 7th, 2019 at 03:18 pm