官网地址:
https://docs.docker.com/install/linux/docker-ce/centos/
这里选择Community (社区)版本
1. 删除自带的docker环境
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
2. 采用yum源方式安装docker
Install using the repository
1) Install required packages. 安装必要组件
sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
2) Use the following command to set up the stable repository 采用稳定yum源
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
3)关闭 nightly or test repository
sudo yum-config-manager --disable docker-ce-nightly
4) 安装最新稳定版docker
sudo yum install docker-ce docker-ce-cli containerd.io
5) 启动
sudo systemctl start docker
6)测试
sudo docker run hello-world
7) 开机启动
sudo systemctl enable docker