一.參考文檔
官方Docker安裝文檔:https://docs.docker.com/install/linux/docker-ce/centos
阿里雲Docker安裝文檔:https://yq.aliyun.com/articles/110806linux
二.安裝步驟
1.刪除已安裝的Dockerdocker
# Uninstall installed docker sudo yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate \ docker-logrotate \ docker-selinux \ docker-engine-selinux \ docker-engine
2.配置阿里雲Docker Yum源centos
# Set up repository sudo yum install -y yum-utils device-mapper-persistent-data lvm2 # Use Aliyun Docker sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
3.安裝指定版本app
查看Docker版本:ui
yum list docker-ce --showduplicates
安裝較舊版本(好比Docker 17.03.2) 時須要指定完整的rpm包的包名,而且加上--setopt=obsoletes=0參數:阿里雲
# Install docker # on a new system with yum repo defined, forcing older version and ignoring obsoletes introduced by 17.06.0 yum install -y --setopt=obsoletes=0 \ docker-ce-17.03.2.ce-1.el7.centos.x86_64 \ docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch
或安裝Docker較新版本(好比Docker 18.03.0)時加上rpm包名的版本號部分:spa
sudo yum install docker-ce-18.03.0.ce
或安裝Docker最新版本,無需加版本號:.net
sudo yum install docker-ce
三.啓動Docker服務code
# Start docker service
systemctl enable docker
systemctl start docker