1、安裝docker引擎

陈奕桦發表於2024-03-20
一、安裝Docker
設定centos yum映象源
cd /etc/yum.repos.d/
mkdir backup && mv *repo backup/
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
yum clean all && yum makecache
yum repolist all
解除安裝舊版本(如果安裝過舊版本的話)
yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine \
docker-ce
安裝需要的軟體包yum-util 提供yum-config-manager功能,另外兩個是devicemapper驅動依賴
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
#設定yum源
yum-config-manager \ --add-repo \ https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sed -i 's/download.docker.com/mirrors.aliyun.com\/docker-ce/g' /etc/yum.repos.d/docker-ce.repo
yum makecache
安裝docker
yum install -y docker-ce
啟動docker
systemctl start docker
驗證是否啟動成功
docker version
設定docker開機自啟
systemctl enable docker
驗證開機自啟是否設定成功
systemctl is-enabled docker
配置映象加速
vim /etc/docker/daemon.json
#新增以下內容:
{ "registry-mirrors": [ "https://mirror.ccs.tencentyun.com" ] } 
重啟docker
systemctl restart docker

二、透過rancher指令碼一鍵快速安裝docker

curl https://releases.rancher.com/install-docker/19.03.sh | sh
curl https://releases.rancher.com/install-docker/20.10.sh | sh

相關文章