跳到主要内容
版本:v3&v6

CentOS 安装 Docker

离线安装

先卸载原有的 docker

yum remove docker*
rm -rf /var/lib/docker

安装 docker

curl -O https://download.docker.com/linux/static/stable/x86_64/docker-20.10.6.tgz
tar -zvxf docker-20.10.6.tgz
cp docker/* /usr/bin

解压上面的 docker-config.tar.gz,复制文件到/etc/systemd/system 目录

cd /tmp
curl -O https://res.ones.pro/script/k3stool/docker-config.tar.gz
tar -zvxf docker-config.tar.gz
cd docker-config
cp docker.service docker.socket containerd.service /etc/systemd/system/

启动 docker

systemctl enable docker
groupadd docker
systemctl start docker

在线安装

先卸载原有的 docker

yum remove docker*
rm -rf /var/lib/docker

安装 docker

sudo yum update
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo sed -i 's/download.docker.com/mirrors.aliyun.com\/docker-ce/g' /etc/yum.repos.d/docker-ce.repo

sudo yum install docker-ce docker-ce-cli containerd.io

启动 docker

sudo systemctl enable docker
groupadd docker
sudo systemctl start docker