一、验证内核版本,要求内核版本必须大于3.10
$ uname -r
二、更新yum源,保证yum包升级到最新
$ yum update
三、安装依赖的软件包
$ yum install -y yum-utils device-mapper-persistent-data lvm2
四、添加docker yum源
$ yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo 或者使用国内镜像源 $ yum-config-manager --add-repo https://mydream.ink/utils/container/docker-ce.repo
五、查看docker版本
$ yum list docker-ce --showduplicates | sort -r
六、安装docker
repo中默认只开启stable仓库,使用以下两个命令分别安装最新版本以及指定版本。
$ yum install docker-ce
$ yum install docker-ce-3:19.03.5
七、加入开机启动
$ systemctl start docker $ systemctl enable docker
八、看是否安装成功
$ docker version Client: Docker Engine - Community Version: 19.03.5 API version: 1.40 Go version: go1.12.12 Git commit: 633a0ea Built: Wed Nov 13 07:25:41 2019 OS/Arch: linux/amd64 Experimental: false Server: Docker Engine - Community Engine: Version: 19.03.5 API version: 1.40 (minimum version 1.12) Go version: go1.12.12 Git commit: 633a0ea Built: Wed Nov 13 07:24:18 2019 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.2.10 GitCommit: b34a5c8af56e510852c35414db4c1f4fa6172339 runc: Version: 1.0.0-rc8+dev GitCommit: 3e425f80a8c931f88e6d94a8c831b9d5aa481657 docker-init: Version: 0.18.0 GitCommit: fec3683