centos7安装Docker

1.把yum包更新到最新

yum update

2. 安装依赖

安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的

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

3. 设置yum源(选择其中一个)

yum-config-manager --add-repo xxxx

4.查看所有仓库中所有docker版本

可以查看所有仓库中所有docker版本,并选择特定版本安装

[root@localhost nexus3]# yum list docker-ce --showduplicates | sort -r
已加载插件:fastestmirror, langpacks
可安装的软件包
 * updates: mirrors.ustc.edu.cn
Loading mirror speeds from cached hostfile
 * extras: ftp.sjtu.edu.cn
docker-ce.x86_64            3:24.0.7-1.el7                      docker-ce-stable
docker-ce.x86_64            3:24.0.6-1.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.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.1.ce-1.el7.centos             docker-ce-stable
docker-ce.x86_64            17.03.0.ce-1.el7.centos             docker-ce-stable
 * base: mirrors.ustc.edu.cn

5.安装Docker

命令:yum install docker-ce-版本号,我选的是docker-ce-18.03.1.ce,如下

[root@localhost nexus3]# yum install docker-ce-18.03.1.ce
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * extras: ftp.sjtu.edu.cn
 * updates: mirrors.ustc.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 docker-ce.x86_64.0.18.03.1.ce-1.el7.centos 将被 安装
--> 正在处理依赖关系 container-selinux >= 2.9,它被软件包 docker-ce-18.03.1.ce-1.el7.centos.x86_64 需要
--> 正在处理依赖关系 pigz,它被软件包 docker-ce-18.03.1.ce-1.el7.centos.x86_64 需要
--> 正在检查事务
---> 软件包 container-selinux.noarch.2.2.119.2-1.911c772.el7_8 将被 安装
---> 软件包 pigz.x86_64.0.2.3.3-1.el7.centos 将被 安装
--> 解决依赖关系完成

依赖关系解决

==============================================================================================================================
 Package                       架构               版本                                     源                            大小
==============================================================================================================================
正在安装:
 docker-ce                     x86_64             18.03.1.ce-1.el7.centos                  docker-ce-stable              35 M
为依赖而安装:
 container-selinux             noarch             2:2.119.2-1.911c772.el7_8                extras                        40 k
 pigz                          x86_64             2.3.3-1.el7.centos                       extras                        68 k

事务概要
==============================================================================================================================
安装  1 软件包 (+2 依赖软件包)

总下载量:35 M
安装大小:35 M
Is this ok [y/d/N]: y
Downloading packages:
(1/3): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm                                            |  40 kB  00:00:00
(2/3): pigz-2.3.3-1.el7.centos.x86_64.rpm                                                              |  68 kB  00:00:00
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-18.03.1.ce-1.el7.centos.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
docker-ce-18.03.1.ce-1.el7.centos.x86_64.rpm 的公钥尚未安装
(3/3): docker-ce-18.03.1.ce-1.el7.centos.x86_64.rpm                                                    |  35 MB  00:01:32
------------------------------------------------------------------------------------------------------------------------------
总计                                                                                          385 kB/s |  35 MB  00:01:32
从 https://mirrors.aliyun.com/docker-ce/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://mirrors.aliyun.com/docker-ce/linux/centos/gpg
是否继续?[y/N]:y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                                        1/3
  正在安装    : pigz-2.3.3-1.el7.centos.x86_64                                                                            2/3
  正在安装    : docker-ce-18.03.1.ce-1.el7.centos.x86_64                                                                  3/3
  验证中      : pigz-2.3.3-1.el7.centos.x86_64                                                                            1/3
  验证中      : docker-ce-18.03.1.ce-1.el7.centos.x86_64                                                                  2/3
  验证中      : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch                                                        3/3

已安装:
  docker-ce.x86_64 0:18.03.1.ce-1.el7.centos

作为依赖被安装:
  container-selinux.noarch 2:2.119.2-1.911c772.el7_8                     pigz.x86_64 0:2.3.3-1.el7.centos

完毕!

6.启动Docker

命令:systemctl start docker,然后加入开机启动,如下

[root@localhost nexus3]# systemctl start docker
[root@localhost nexus3]# docker -v
Docker version 18.03.1-ce, build 9ee9f40
[root@localhost nexus3]# systemctl enable  docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@localhost nexus3]# docker version
Client:
 Version:      18.03.1-ce
 API version:  1.37
 Go version:   go1.9.5
 Git commit:   9ee9f40
 Built:        Thu Apr 26 07:20:16 2018
 OS/Arch:      linux/amd64
 Experimental: false
 Orchestrator: swarm

Server:
 Engine:
  Version:      18.03.1-ce
  API version:  1.37 (minimum version 1.12)
  Go version:   go1.9.5
  Git commit:   9ee9f40
  Built:        Thu Apr 26 07:23:58 2018
  OS/Arch:      linux/amd64
  Experimental: false
  • 4
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值