Docker從1.13版本以後採用時間線的方式做爲版本號,分爲社區版CE和企業版EE。linux
Docker CE 即社區免費版,Docker EE 即企業版,強調安全,但需付費使用。企業版會提供額外的收費服務,好比通過官方測試認證過的基礎設施、容器、插件等。docker
社區版按照stable和edge兩種方式發佈,每一個季度更新stable版本,如17.06,17.09;每月份更新edge版本,如17.09,17.10。json
目前,CentOS 僅發行版本中的內核支持 Docker。centos
Docker 運行在 CentOS 7 上,要求系統爲64位、系統內核版本爲 3.10 以上。緩存
Docker 運行在 CentOS-6.5 或更高的版本的 CentOS 上,要求系統爲64位、系統內核版本爲 2.6.32-431 或者更高版本。安全
一、Docker 要求 CentOS 系統的內核版本高於 3.10 ,查看本頁面的前提條件來驗證你的CentOS 版本是否支持 Docker 。
經過 uname -r 命令查看你當前的內核版本服務器
[root@localhost ~]# uname -r 3.10.0-862.11.6.el7.x86_64
二、使用 root 權限登陸 Centos。確保 yum 包更新到最新。網絡
[root@localhost ~]# sudo yum update
三、卸載舊版本(若是安裝過舊版本的話)app
$ 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
四、安裝須要的軟件包, yum-util 提供yum-config-manager功能,另外兩個是devicemapper驅動依賴的[root@localhost ~]# sudo yum install -y yum-utils device-mapper-persistent-data lvm2
ide
五、設置yum源sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
六、更新 yum 緩存:sudo yum makecache fast
七、能夠查看全部倉庫中全部docker版本,並選擇特定版本安裝
[root@bogon ~]# yum list docker-ce --showduplicates | sort -r 已加載插件:fastestmirror 可安裝的軟件包 * updates: mirrors.tuna.tsinghua.edu.cn Loading mirror speeds from cached hostfile * extras: mirrors.tuna.tsinghua.edu.cn docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable docker-ce.x86_64 18.03.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable 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 docker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable * base: mirrors.tuna.tsinghua.edu.cn
八、安裝docker
#因爲repo中默認只開啓stable倉庫,故這裏安裝的是最新穩定版18.06.1 [root@bogon ~]# sudo yum install docker-ce # 指定版本安裝 [root@bogon ~]# yum install https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/7/x86_64/stable/Packages/docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch.rpm [root@bogon ~]# sudo yum install docker-ce-17.03.2.ce
九、啓動並加入開機啓動
[root@bogon ~]# sudo systemctl start docker [root@bogon ~]# sudo systemctl enable docker Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
十、驗證安裝是否成功(有client和service兩部分表示docker安裝啓動都成功了)
[root@bogon ~]# docker version
鑑於國內網絡問題,後續拉取 Docker 鏡像十分緩慢,咱們能夠須要配置加速器來解決。
在 /etc/docker/daemon.json 中寫入以下內容(若是文件不存在請新建該文件)
{ "registry-mirrors": [ "https://registry.docker-cn.com" ] }
注意,必定要保證該文件符合 json 規範,不然 Docker 將不能啓動。
以後從新啓動服務。
若是卸載 Docker CE,執行如下命令:
[root@bogon ~]# sudo yum remove docker-ce [root@bogon ~]# sudo rm -rf /var/lib/docker
因爲 docker 官方服務器位於國外,下載速度可能異常緩慢,建議將官方源下載地址替換爲清華大學鏡像源後進行安裝。
#替換docker官方源下載地址 sudo sed -i 's+download.docker.com+mirrors.tuna.tsinghua.edu.cn/docker-ce+' /etc/yum.repos.d/docker-ce.repo #清除緩存 sudo yum clean all #從新創建緩存 sudo yum makecache #安裝docker-ce sudo yum install docker-ce