官網文檔:https://docs.docker.com/engine/installation/linux/centos/ ,本文大部分是照搬官方文檔寫的,如果你英文還不錯,那么就直接移步官方文檔吧,如果你英文實在是不行,那就勉強看一下本人這生澀的翻譯~
以下操作均在root用戶下完成
docker的安裝要求64位系統(tǒng)且內核版本大于3.10。所以如果是centos的話,必須安裝CentOS7.0或以上版本。
我們這里使用的是CentOS7.2 mininul。uname -r
3.10.0-327.28.3.el7.x86_64安裝docker前執(zhí)行一下全系統(tǒng)的軟件版本升級:
yum -y update1.配置yum軟件庫
為保證安裝的成功,首先使用yum update更新Yum包,表示我的好多yum包都需要更新,1500+的包,如果你像我一樣好久沒有更新過,那就耐心等候吧。
然后在yum軟件庫中新增docker的配置:# tee /etc/yum.repos.d/docker.repo <<-'EOF'[dockerrepo]name=Docker Repositorybaseurl=https://yum.dockerproject.org/repo/main/centos/7/enabled=1gpgcheck=1gpgkey=https://yum.dockerproject.org/gpgEOF
2.安裝Docker
有了yum軟件庫的配置之后,安裝也變得異常的簡單,只需要以下一句即可:
# yum install docker-engine
3.啟動Docker
一切就緒之后,使用start命令來啟動Docker守護進程:# service docker start
4.輸出hello-world
程序員貌似跟hello-world有仇,有事兒沒事就打印人家一下,玩docker咱們當前也不例外,先來個hello-world吧,這里的基本原理是利用人家已經寫好的hello-world鏡像,下載到本地,然后把他運行起來~使用以下命令:
# docker run hello-world
然后控制端會輸出類似于如下的信息,就證明我們的docker環(huán)境安裝成功了~

在這里,我第一次失敗了~顯示:
Unable to find image 'hello-world:latest' locallydocker: Error response from daemon: Get https://registry-1.docker.io/v2/library/hello-world/manifests/latest: Get https://auth.docker.io/token?scope=repository%3Alibrary%2Fhello-world%3Apull&service=registry.docker.io: net/http: TLS handshake timeout.See 'docker run --help'.
然后我又來了一次就好了,應該是墻的原因吧,看著是網絡訪問失敗了~
Unable to find image 'hello-world:latest' locallylatest: Pulling from library/hello-worldc04b14da8d14: Pull complete Digest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9Status: Downloaded newer image for hello-world:latestHello 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. 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 bashShare images, automate workflows, and more with a free Docker Hub account: https://hub.docker.comFor more examples and ideas, visit: https://docs.docker.com/engine/userguide/
新聞熱點
疑難解答