Ubuntu 20 Docker安裝指令碼
阿新 • • 發佈:2021-09-29
Ubuntu 20 Docker安裝指令碼
安裝指令碼適用於Ubuntu 20 LTS,指令碼將會安裝Docker,SSH,CURL等軟體,安裝完畢後重啟系統
Docker版本為最新版本,指令碼將自動配置Docker加速源
#! /bin/bash # 適用於Ubuntu 20 #安裝Vim Git g++ ssh 等服務 sudo apt-get update sudo apt install vim git g++ ssh python3-pip curl -y # 安裝Docker sudo apt-get remove docker docker-engine docker.io containerd runc -y sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg \ lsb-release -y curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg echo \ "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io -y # 新增docker源加速,並設定容器驅動為kubeadm推薦的systemd sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<-'EOF' { "exec-opts": ["native.cgroupdriver=systemd"], "log-driver": "json-file", "log-opts": { "max-size": "100m" },"registry-mirrors":["https://registry.docker-cn.com"], "storage-driver": "overlay2", "storage-opts": [ "overlay2.override_kernel_check=true" ] } EOF # 添加當前使用者到docker組 sudo gpasswd -a ${USER} docker && echo "docker ${USER} group add !!!!" || echo "fail!!!!!!!!!!!!" sudo systemctl daemon-reload sudo systemctl enable docker sudo systemctl restart docker