清理旧的Docker
yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-selinux docker-engine-selinux docker-engine -y
安装依赖yum install -y yum-utils device-mapper-persistent-data lvm2
配置阿里云Docker源yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
查看源中的版本yum list docker-ce.x86_64 --showduplicates | sort -r
安装Docker
yum -y install docker-ce-19.03.5-3.el7
设置开机启动并启动服务
systemctl enable docker
systemctl start docker
镜像加速,修改源,并修改docker的驱动方式
vi /etc/docker/daemon.json
{
"registry-mirrors": ["https://i7sdzehw.mirror.aliyuncs.com"]
}
sudo systemctl daemon-reload
sudo systemctl restart docker
如果要更改docker的数据目录/etc/docker/daemon.json增加如下内容"graph": "/docker/data/path",
测试拉取和运行
docker pull library/hello-world
docker run hello-world