CentOS 7安裝Docker CE

Docker現(xiàn)在分為兩個(gè)版本,Docker CE和Docker EE
其中Docker CE為開源版,Docker EE為企業(yè)版
本文為Docker CE的部署,環(huán)境為CentOS 7,VMware虛擬機(jī)一臺(tái)(CentOS原生YUM源)
Docker官網(wǎng) https://www.docker.com/
本文參考官方部署文檔 https://docs.docker.com/install/linux/docker-ce/centos/#prerequisites

1.卸載舊版本(確保沒有舊版本的Docker殘留文件)

$ 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報(bào)告沒有安裝以上軟件即可
2.安裝Docker CE
安裝Docker的方法有三種,通過官方y(tǒng)um源進(jìn)行安裝、下載RPM包手動(dòng)安裝,使用一些腳本進(jìn)行安裝
在這里有正常聯(lián)網(wǎng)能力的用戶建議選擇用官方y(tǒng)um源進(jìn)行安裝即可
首先安裝存儲(chǔ)驅(qū)動(dòng)

$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2

下載官方y(tǒng)um源文件

$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

(可選)啟用邊緣和測試存儲(chǔ)庫,通常是禁用狀態(tài),也可以選擇啟用

$ sudo yum-config-manager --enable docker-ce-edge
$ sudo yum-config-manager --enable docker-ce-test

如果啟用后后悔的話可以使用以下命令禁用邊緣和測試存儲(chǔ)庫

$ sudo yum-config-manager --disable docker-ce-edge

到這里就可以開始安裝Docker CE了

$ sudo yum install docker-ce

到這里你也許會(huì)感覺到下載速度奇慢無比,但實(shí)際上也就是docker-ce-17.12.1.ce-1.el7.centos.x86_64.rpm這個(gè)文件下載緩慢
所以這里建議可以的話自己下載下來這個(gè)包進(jìn)行安裝會(huì)比較好一些

下載鏈接
https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-17.12.1.ce-1.el7.centos.x86_64.rpm

另外關(guān)于Docker的版本號(hào),2017年2月開始Docker官方啟用了新的版本號(hào)規(guī)則,之前的1.12.6之類的停用,轉(zhuǎn)而使用17.2.1這樣的版本號(hào),這個(gè)版本號(hào)的意思就是17年2月的第1個(gè)版本
所以可以的話請到官網(wǎng)查詢當(dāng)前最新版本號(hào)再進(jìn)行下載,我這里部署時(shí)間為18年3月,當(dāng)前最新版本號(hào)依然是17.12.1,即為17年12月發(fā)布的版本

$ yum -y install lrzsz
$ rz -E
$ yum -y install docker-ce-17.12.1.ce-1.el7.centos.x86_64.rpm 

Complete!

在生產(chǎn)環(huán)境Docker官方建議安裝特定版本的Docker CE,而不是始終使用最新版本
使用以下命令查看可用的版本

$ yum list docker-ce --showduplicates | sort -r
docker-ce.x86_64            17.12.1.ce-1.el7.centos             installed       
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

3.啟動(dòng)Docker

$ sudo systemctl start docker

4.驗(yàn)證安裝是否正確

$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete 
Digest: sha256:083de497cff944f969d8499ab94f07134c50bcf5e6b9559b27182d3fa80ce3f7
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://cloud.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

簡單翻譯一下

來自Docker的問候!
此消息表明您的安裝似乎正常工作。

為了生成此消息,Docker采取了以下步驟:
 1. Docker客戶端聯(lián)系了Docker守護(hù)進(jìn)程。
 2. Docker守護(hù)進(jìn)程從Docker Hub中提取“hello-world”圖像。
    (AMD64)
 3. Docker守護(hù)進(jìn)程從運(yùn)行該映像的映像創(chuàng)建一個(gè)新的容器
    可執(zhí)行文件生成您正在閱讀的輸出。
 4. Docker守護(hù)進(jìn)程將輸出流式傳輸?shù)桨l(fā)送它的Docker客戶端
    到您的終端。

要嘗試更雄心勃勃的事情,你可以運(yùn)行一個(gè)Ubuntu容器:
 $ docker run -it ubuntu bash

通過免費(fèi)的Docker ID共享圖像,自動(dòng)化工作流程等等:
 https://cloud.docker.com/

有關(guān)更多示例和想法,請?jiān)L問:
 https://docs.docker.com/engine/userguide/

與此同此你的Docker鏡像庫中多了一個(gè)Hello-world,你的Docker容器庫中也多了一個(gè)Hello-world

$ docker image list
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              f2a91732366c        3 months ago        1.85kB
$ docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                     PORTS               NAMES
4b0296d18849        hello-world         "/hello"            8 minutes ago       Exited (0) 8 minutes ago                       hopeful_yonath

4.升級Docker CE

$ yum -y upgrade 你的新版本docker文件
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 簡單版: 1.執(zhí)行命令curl -sSL https://get.daocloud.io/docker | sh ...
    Yetta的書影屋閱讀 4,424評論 0 49
  • 1、先決條件 安裝Docker CE,您需要CentOS 7的維護(hù)版本。 需要啟用centos-extras倉庫。...
    DanielJI閱讀 459評論 0 0
  • 官方文檔個(gè)人翻譯當(dāng)前時(shí)間:2017年07月18日20:01:57 若想要在CentOS上使用Docker CE(社...
    MR_ChanHwang閱讀 1,196評論 0 4
  • 2月3日是正月初七,老百姓所說的人日子,按照我國的傳統(tǒng)(традиция),家家都要吃面條(лапша),寓...
    張春霖閱讀 455評論 4 3
  • “這次行動(dòng),我負(fù)責(zé)對付這個(gè)孫瘋子,你們一定要遠(yuǎn)離他,不要讓他有給你們下蠱的機(jī)會(huì)。”郭老六囑咐著小白等人。 “郭爺爺...
    小白醬bai閱讀 288評論 0 1

友情鏈接更多精彩內(nèi)容