天天看點

docker安裝腳本,整理自阿裡雲鏡像站 - kcrist

docker安裝腳本,整理自阿裡雲鏡像站

#!/bin/bash
DEBIAN=$(uname -v |grep -o Debian)
CENTOS=$( uname -r |grep -o el7)
if [ $DEBIAN ];
then
# step 1: 安裝必要的一些系統工具
 sed -i \'s@GRUB_CMDLINE_LINUX="@GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1 @\' /etc/default/grub
 update-grub
 apt-get update
 apt-get -y install apt-transport-https ca-certificates curl software-properties-common
# step 2: 安裝GPG證書
 curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
# Step 3: 寫入軟體源資訊
 add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/debian $(lsb_release -cs) stable"
# Step 4: 更新并安裝 Docker-CE
 apt-get -y update
 apt-get -y install docker-ce
elif [ $CENTOS ];
then
# step 1: 安裝必要的一些系統工具
 yum install -y yum-utils device-mapper-persistent-data lvm2
 sed -i \'s@GRUB_CMDLINE_LINUX="@GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1 @\' /etc/default/grub
 grub2-mkconfig -o /boot/grub2/grub.cfg
# Step 2: 添加軟體源資訊
 yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# Step 3: 更新并安裝 Docker-CE
 yum makecache fast
 yum -y install docker-ce
# Step 4: 開啟Docker服務
 service docker start
else
 echo "unkown release"
 exit 1
fi      

#配置docker鏡像加速源,此為國内第三方鏡像站,用着挺快的,有更好的歡迎推薦

curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | bash -s http://89357acc.m.daocloud.io

#添加自啟,重新開機服務

systemctl enable docker

systemctl restart docker

docker安裝腳本,整理自阿裡雲鏡像站 - kcrist