指定yum文件
cat /etc/yum.repos.d/docker-ce.repo
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-stable-debuginfo]
name=Docker CE Stable - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/stable enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
docker-ce-stable-source]
name=Docker CE Stable - Sources
baseurl=https://download.docker.com/linux/centos/7/source/stable enabled=0 gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-edge]
name=Docker CE Edge - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/edge enabled=1 gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-edge-debuginfo]
name=Docker CE Edge - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/edge enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
docker-ce-edge-source]
name=Docker CE Edge - Sources
baseurl=https://download.docker.com/linux/centos/7/source/edge enabled=0 gpgcheck=1gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-test]
name=Docker CE Test - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/test enabled=0 gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-test-debuginfo]
name=Docker CE Test - Debuginfo $basearch
baseurl=https://download.docker.com/linux/centos/7/debug-$basearch/test enabled=0
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-test-source]
name=Docker CE Test - Sources
baseurl=https://download.docker.com/linux/centos/7/source/test enabled=0 gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
执行yum命令
yum install -y docker-ce
systemctl enable docker && systemctl start docker
安装docker源,yum安装docker-ce下载速度很慢
安装yum管理包
yum install -y yum-utilsdevice-mapper-persistent-data lvm2
添加docker镜像源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
安装docker-ce
yum install -y docker-ce
启动docker-ce服务
systemctl enable docker && systemctl start docker