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 ~]#

安装到此结束

 

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