centos 7 安裝docker

由於Docker 要求 centos 系統的內核版本高於 3.10 ,首先查看centos 的內核版本

[root@localhost ~]# uname -r
3.10.0-514.el7.x86_64
[root@localhost ~]#

安裝需要的軟件:

[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
已加載插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * extras: mirrors.163.com
 * updates: mirrors.aliyun.com
軟件包 device-mapper-persistent-data-0.7.3-3.el7.x86_64 已安裝並且是最新版本
軟件包 7:lvm2-2.02.180-10.el7_6.7.x86_64 已安裝並且是最新版本
正在解決依賴關係
--> 正在檢查事務
---> 軟件包 yum-utils.noarch.0.1.1.31-50.el7 將被 安裝
--> 正在處理依賴關係 python-kitchen,它被軟件包 yum-utils-1.1.31-50.el7.noarch 需要
--> 正在處理依賴關係 libxml2-python,它被軟件包 yum-utils-1.1.31-50.el7.noarch 需要
--> 正在檢查事務
---> 軟件包 libxml2-python.x86_64.0.2.9.1-6.el7_2.3 將被 安裝
---> 軟件包 python-kitchen.noarch.0.1.1.1-5.el7 將被 安裝
--> 正在處理依賴關係 python-chardet,它被軟件包 python-kitchen-1.1.1-5.el7.noarch 需要
--> 正在檢查事務
---> 軟件包 python-chardet.noarch.0.2.2.1-1.el7_1 將被 安裝
--> 解決依賴關係完成

依賴關係解決

===================================================================================
 Package                架構           版本                     源            大小
===================================================================================
正在安裝:
 yum-utils              noarch         1.1.31-50.el7            base         121 k
爲依賴而安裝:
 libxml2-python         x86_64         2.9.1-6.el7_2.3          base         247 k
 python-chardet         noarch         2.2.1-1.el7_1            base         227 k
 python-kitchen         noarch         1.1.1-5.el7              base         267 k

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

總下載量:861 k
安裝大小:4.3 M
Downloading packages:
(1/4): libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm            | 247 kB  00:00:05     
(2/4): yum-utils-1.1.31-50.el7.noarch.rpm                   | 121 kB  00:00:06     
(3/4): python-chardet-2.2.1-1.el7_1.noarch.rpm              | 227 kB  00:00:07     
(4/4): python-kitchen-1.1.1-5.el7.noarch.rpm                | 267 kB  00:00:08     
-----------------------------------------------------------------------------------
總計                                                  102 kB/s | 861 kB  00:08     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安裝    : python-chardet-2.2.1-1.el7_1.noarch                            1/4 
  正在安裝    : python-kitchen-1.1.1-5.el7.noarch                              2/4 
  正在安裝    : libxml2-python-2.9.1-6.el7_2.3.x86_64                          3/4 
  正在安裝    : yum-utils-1.1.31-50.el7.noarch                                 4/4 
  驗證中      : libxml2-python-2.9.1-6.el7_2.3.x86_64                          1/4 
  驗證中      : python-kitchen-1.1.1-5.el7.noarch                              2/4 
  驗證中      : yum-utils-1.1.31-50.el7.noarch                                 3/4 
  驗證中      : python-chardet-2.2.1-1.el7_1.noarch                            4/4 

已安裝:
  yum-utils.noarch 0:1.1.31-50.el7                                                 

作爲依賴被安裝:
  libxml2-python.x86_64 0:2.9.1-6.el7_2.3   python-chardet.noarch 0:2.2.1-1.el7_1  
  python-kitchen.noarch 0:1.1.1-5.el7      

完畢!
[root@localhost ~]# 

設置yum源

[root@localhost ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
已加載插件:fastestmirror
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[root@localhost ~]# 

查看docker版本

[root@localhost ~]# yum list docker-ce --showduplicates | sort -r
已加載插件:fastestmirror
可安裝的軟件包
 * updates: mirrors.aliyun.com
Loading mirror speeds from cached hostfile
 * extras: mirrors.163.com
docker-ce.x86_64            3:18.09.6-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.5-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.4-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.3-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.2-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.1-3.el7                     docker-ce-stable
docker-ce.x86_64            3:18.09.0-3.el7                     docker-ce-stable
docker-ce.x86_64            18.06.3.ce-3.el7                    docker-ce-stable
docker-ce.x86_64            18.06.2.ce-3.el7                    docker-ce-stable
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.3.ce-1.el7                    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.aliyun.com
[root@localhost ~]# 

安裝docker

yum install docker-ce

已安裝:
  docker-ce.x86_64 3:18.09.6-3.el7                                                 

作爲依賴被安裝:
  audit-libs-python.x86_64 0:2.8.4-4.el7                                           
  checkpolicy.x86_64 0:2.5-8.el7                                                   
  container-selinux.noarch 2:2.95-2.el7_6                                          
  containerd.io.x86_64 0:1.2.5-3.1.el7                                             
  docker-ce-cli.x86_64 1:18.09.6-3.el7                                             
  libcgroup.x86_64 0:0.41-20.el7                                                   
  libsemanage-python.x86_64 0:2.5-14.el7                                           
  policycoreutils-python.x86_64 0:2.5-29.el7_6.1                                   
  python-IPy.noarch 0:0.75-6.el7                                                   
  setools-libs.x86_64 0:3.3.8-4.el7                                                

完畢!
[root@localhost ~]#

啓動docker並設置開機啓動

[root@localhost ~]# systemctl start docker
[root@localhost ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@localhost ~]# 

查看是否安裝和啓動成功,有client 和server 算成功

[root@localhost ~]# docker version
Client:
 Version:           18.09.6
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        481bc77156
 Built:             Sat May  4 02:34:58 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.6
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.8
  Git commit:       481bc77
  Built:            Sat May  4 02:02:43 2019
  OS/Arch:          linux/amd64
  Experimental:     false
[root@localhost ~]# ^C
[root@localhost ~]#

安裝到此結束

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章