每次安装都要去看官方文档,比较烦。所以把官网的搬过来。官网链接:https://docs.docker.com/install/linux/docker-ce/centos/
#卸载已有的Docker
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
#依赖安装
sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
#增加YUM源
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
#启用YUM源
sudo yum-config-manager --enable docker-ce-nightly
#安装
sudo yum install docker-ce docker-ce-cli containerd.io
#启用服务
sudo systemctl start docker
#测试
sudo docker run hello-world