卸载旧版本
sudo yum remove -y docker \\
docker-client \\
docker-client-latest \\
docker-common \\
docker-latest \\
docker-latest-logrotate \\
docker-logrotate \\
docker-selinux \\
docker-engine-selinux \\
docker-engine
设置 yum repository
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo <https://download.docker.com/linux/centos/docker-ce.repo>
安装并启动 docker
sudo yum install -y docker-ce docker-ce-cli containerd.io
sudo systemctl enable docker
sudo systemctl start docker
设置docker源(用于加速docker镜像的拉取,可选)以下为阿里云docker源
sudo vi /etc/docker/daemon.json
{
"registry-mirrors": ["<https://h64mkioy.mirror.aliyuncs.com>"]
}
修改docker的存储路径,避免直接使用系统盘
vi /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd 后面加上 --graph /data/docker
sudo systemctl daemon-reload
sudo systemctl restart docker