前置條件linux
64-bit 系統
kernel 3.10+
一.檢查內核版本,返回的值大於3.10便可docker
$ uname -r
二.使用 sudo 或 root 權限的用戶登入終端centos
三.卸載舊版本(若是安裝過舊版本的話)app
$ yum remove docker \ docker-common \ docker-selinux \ docker-engine
四.安裝須要的軟件包ui
#yum-util提供yum-config-manager功能 #另外兩個是devicemapper驅動依賴的 $ yum install -y yum-utils \ device-mapper-persistent-data \ lvm2
五.設置yum源spa
$ yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo
六.安裝docker插件
1.安裝最新版本code
$ yum install -y docker-ce
2.安裝指定版本blog
#查詢版本列表 $ yum list docker-ce --showduplicates | sort -r 已加載插件:fastestmirror, langpacks 已安裝的軟件包 可安裝的軟件包 * updates: mirrors.163.com Loading mirror speeds from cached hostfile * extras: mirrors.163.com docker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stable ... #指定版本安裝(這裏的例子是安裝上面列表中的第二個) $ yum install -y docker-ce-17.09.0.ce
七.啓動dockerrem
$ systemctl start docker.service
八.驗證安裝是否成功(有client和service兩部分表示docker安裝啓動都成功了)
$ docker version Client: Version: 17.09.0-ce API version: 1.32 Go version: go1.8.3 Git commit: afdb6d4 Built: Tue Sep 26 22:41:23 2017 OS/Arch: linux/amd64 Server: Version: 17.09.0-ce API version: 1.32 (minimum version 1.12) Go version: go1.8.3 Git commit: afdb6d4 Built: Tue Sep 26 22:42:49 2017 OS/Arch: linux/amd64 Experimental: false