Centos 7系統在線安裝docker

在線安裝docker

如下操做步驟均在root用戶下操做linux

一、 檢查內核是否符合要求

Docker 要求 Centos系統的內核版本高於 3.10 ,建議在Centos 7版本
命令以下:git

uname -r

執行過程以下:docker

[root@localhost yum.repos.d]# uname -r
3.10.0-693.el7.x86_64ubuntu

二、 配置docker鏡像源

命令以下:centos

wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
yum makecache

執行過程以下:緩存

[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
--2018-02-09 07:51:02-- https://download.docker.com/linux/centos/docker-ce.repo
正在解析主機 download.docker.com (download.docker.com)... 205.251.203.37, 205.251.203.39, 205.251.203.182, ...
正在鏈接 download.docker.com (download.docker.com)|205.251.203.37|:443... 已鏈接。
已發出 HTTP 請求,正在等待迴應... 200 OK
長度:2424 (2.4K) [binary/octet-stream]
正在保存至: 「/etc/yum.repos.d/docker-ce.repo」
100%[================================================================================>] 2,424 --.-K/s 用時 0s
2018-02-09 07:51:04 (320 MB/s) - 已保存 「/etc/yum.repos.d/docker-ce.repo」 [2424/2424])
[root@localhost ~]# yum makecache
已加載插件:fastestmirror, langpacks
base | 3.6 kB 00:00:00
docker-ce-stable | 2.9 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/3): docker-ce-stable/x86_64/primary_db | 11 kB 00:00:01
(2/3): docker-ce-stable/x86_64/filelists_db | 6.5 kB 00:00:01
(3/3): docker-ce-stable/x86_64/other_db | 65 kB 00:00:00
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
元數據緩存已創建

三、 安裝docker依賴包

命令以下:bash

yum remove docker docker-common docker-selinux docker-engine
yum install -y yum-utils device-mapper-persistent-data lvm2

執行過程以下:架構

[root@localhost ~]# yum remove docker docker-common docker-selinux docker-engine 刪除老版本
已加載插件:fastestmirror, langpacks
參數 docker 沒有匹配
參數 docker-common 沒有匹配
參數 docker-selinux 沒有匹配
參數 docker-engine 沒有匹配
不刪除任何軟件包
[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data lvm2 安裝依賴包
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
。。。。。。
。。。。。。
更新完畢:
device-mapper-persistent-data.x86_64 0:0.7.0-0.1.rc6.el7_4.1
完畢app

四、 安裝docker-ce

命令以下:ide

yum install docker-ce

執行過程以下:

[root@localhost ~]# yum install docker-ce
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
base: mirrors.aliyun.com extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
正在解決依賴關係
--> 正在檢查事務
---> 軟件包 docker-ce.x86_64.0.17.12.0.ce-1.el7.centos 將被 安裝
--> 正在處理依賴關係 container-selinux >= 2.9,它被軟件包 docker-ce-17.12.0.ce-1.el7.centos.x86_64 須要
--> 正在檢查事務
---> 軟件包 container-selinux.noarch.2.2.36-1.gitff95335.el7 將被 安裝
--> 解決依賴關係完成

依賴關係解決

===============================================================================
Package 架構 版本 源 大小
===============================================================================
正在安裝:
docker-ce x86_64 17.12.0.ce-1.el7.centos docker-ce-stable 30 M
爲依賴而安裝:
container-selinux noarch 2:2.36-1.gitff95335.el7 extras 31 k

事務概要
===============================================================================
安裝 1 軟件包 (+1 依賴軟件包)

總下載量:30 M
安裝大小:123 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): container-selinux-2.36-1.gitff95335.el7.noarch.rpm | 31 kB 00:00:01
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-17.12.0.ce-1.el7.centos.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
docker-ce-17.12.0.ce-1.el7.centos.x86_64.rpm 的公鑰還沒有安裝
(2/2): docker-ce-17.12.0.ce-1.el7.centos.x86_64.rpm | 30 MB 00:00:06
----------------------------------------------------------------------------------
總計 4.4 MB/s | 30 MB 00:00:06
https://download.docker.com/linux/centos/gpg 檢索密鑰
導入 GPG key 0x621E9F35:
用戶ID : "Docker Release (CE rpm) docker@docker.com"
指紋 : 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
來自 : https://download.docker.com/linux/centos/gpg
是否繼續?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安裝 : 2:container-selinux-2.36-1.gitff95335.el7.noarch 1/2
正在安裝 : docker-ce-17.12.0.ce-1.el7.centos.x86_64 2/2
驗證中 : 2:container-selinux-2.36-1.gitff95335.el7.noarch 1/2
驗證中 : docker-ce-17.12.0.ce-1.el7.centos.x86_64 2/2
已安裝:
docker-ce.x86_64 0:17.12.0.ce-1.el7.centos
做爲依賴被安裝:
container-selinux.noarch 2:2.36-1.gitff95335.el7
完畢!

五、 啓動docker 後臺服務

命令以下:

systemctl start docker

執行過程以下:

[root@localhost ~]# systemctl start docker

六、 測試運行hello-world

命令以下:

docker run hello-world

執行過程以下:

[root@localhost ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
ca4f61b1923c: Pull complete
Digest: sha256:66ef312bbac49c39a89aa9bcc3cb4f3c9e7de3788c944158df3ee0176d32b751
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/
相關文章
相關標籤/搜索