centOS7、8安装docker

1、卸载旧docker

sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine

2、安装所需的软件包

sudo yum install -y yum-utils device-mapper-persistent-data lvm2

3、设置稳定的仓库

sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

4、安装docker

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

安装过程有一些提示,按  y  确认。

如果报错:Problem: package docker-ce-3:19.03.4-3.el7.x86_64 requires containerd.io >= 1.2.2-3 那就先装新版的 containerd.io

dnf install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.6-3.3.el7.x86_64.rpm

5、启动docker

sudo systemctl start docker

6、hello-world测试是否成功

sudo docker run hello-world