Centos7上安裝docker
Docker從1.13版本之后采用時間線的方式作為版本號温鸽,分為社區(qū)版CE和企業(yè)版EE。
社區(qū)版是免費(fèi)提供給個人開發(fā)者和小型團(tuán)體使用的手负,企業(yè)版會提供額外的收費(fèi)服務(wù)涤垫,比如經(jīng)過官方測試認(rèn)證過的基礎(chǔ)設(shè)施、容器竟终、插件等蝠猬。
社區(qū)版按照stable和edge兩種方式發(fā)布,每個季度更新stable版本衡楞,如17.06吱雏,17.09敦姻;每個月份更新edge版本瘾境,如17.09,17.10镰惦。
一迷守、安裝docker
1、Docker 要求 CentOS 系統(tǒng)的內(nèi)核版本高于 3.10 旺入,查看本頁面的前提條件來驗(yàn)證你的CentOS 版本是否支持 Docker 兑凿。
通過 **uname -r **命令查看你當(dāng)前的內(nèi)核版本
<pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;"> $ uname -r</pre>
2、使用 root
權(quán)限登錄 Centos茵瘾。確保 yum 包更新到最新礼华。
<pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">$ sudo yum update</pre>
3、卸載舊版本(如果安裝過舊版本的話)
<pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">$ sudo yum remove docker docker-common docker-selinux docker-engine</pre>
4拗秘、安裝需要的軟件包圣絮, yum-util 提供yum-config-manager功能,另外兩個是devicemapper驅(qū)動依賴的
<pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2</pre>
5雕旨、設(shè)置yum源
<pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo</pre>
6扮匠、可以查看所有倉庫中所有docker版本捧请,并選擇特定版本安裝
<pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">$ yum list docker-ce --showduplicates | sort -r</pre>
7、安裝docker
<pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;"> sudo yum install <FQPN> # 例如:sudo yum install docker-ce-17.12.0.ce</pre>
8疹蛉、啟動并加入開機(jī)啟動
<pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;"> sudo systemctl enable docker</pre>
9、驗(yàn)證安裝是否成功(有client和service兩部分表示docker安裝啟動都成功了)
<pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">$ docker version</pre>
二力麸、問題
1可款、因?yàn)橹耙呀?jīng)安裝過舊版本的docker,在安裝的時候報(bào)錯如下:
<pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">Transaction check error: file /usr/bin/docker from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64 file /usr/bin/docker-containerd from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64 file /usr/bin/docker-containerd-shim from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64 file /usr/bin/dockerd from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64</pre>
2克蚂、卸載舊版本的包
<pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">$ sudo yum erase docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64</pre>
3筑舅、再次安裝docker
<pre style="margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">$ sudo yum install docker-ce</pre>