阅读 138

CentOS7中配置Docker的yum源并安装使用详解

这篇文章主要介绍了CentOS7中配置Docker的yum源并安装使用详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

此处使用的是CentOS7,内核版本为

1
2
[root@localhost ~]# uname -r
3.10.0-327.el7.x86_64

该版本下,配置了yum的源为阿里的镜像源,具体的配置方法可以参见阿里镜像源配置方法

为了方便的安装升级Docker,同时按照Docker官方文档中的方式,配置Docker的yum源,具体参见CentOS docker yum 源配置方法 https://docs.docker.com/v1.13/engine/installation/linux/centos/

配置好yum源之后,可以通过yum的list命令,获取可以安装的docker版本

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@localhost ~]# yum list docker --showduplicates |sort -r
 * updates: mirrors.aliyun.com
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror, priorities
 * extras: mirrors.aliyun.com
 * epel: mirrors.aliyun.com
docker.x86_64       2:1.12.6-28.git1398f24.el7.centos       extras
docker.x86_64       2:1.12.6-16.el7.centos             extras
docker.x86_64       2:1.12.6-11.el7.centos             extras
docker.x86_64       2:1.12.5-14.el7.centos             extras
docker.x86_64       2:1.10.3-59.el7.centos             extras
 * base: mirrors.aliyun.com
Available Packages
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
[root@localhost ~]# yum list docker-engine.x86_64 --showduplicates |sort -r
 * updates: mirrors.aliyun.com
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror, priorities
Installed Packages
 * extras: mirrors.aliyun.com
 * epel: mirrors.aliyun.com
docker-engine.x86_64      1.9.1-1.el7.centos         docker-main
docker-engine.x86_64      1.9.0-1.el7.centos         docker-main
docker-engine.x86_64      1.8.3-1.el7.centos         docker-main
docker-engine.x86_64      1.8.2-1.el7.centos         docker-main
docker-engine.x86_64      1.8.1-1.el7.centos         docker-main
docker-engine.x86_64      1.8.0-1.el7.centos         docker-main
docker-engine.x86_64      1.7.1-1.el7.centos         docker-main
docker-engine.x86_64      17.05.0.ce-1.el7.centos       docker-main
docker-engine.x86_64      17.04.0.ce-1.el7.centos       docker-main
docker-engine.x86_64      17.03.1.ce-1.el7.centos       docker-main
docker-engine.x86_64      17.03.0.ce-1.el7.centos       docker-main
docker-engine.x86_64      1.7.0-1.el7.centos         docker-main
docker-engine.x86_64      1.13.1-1.el7.centos         docker-main
docker-engine.x86_64      1.13.1-1.el7.centos         @docker-main
docker-engine.x86_64      1.13.0-1.el7.centos         docker-main
docker-engine.x86_64      1.12.6-1.el7.centos         docker-main
docker-engine.x86_64      1.12.5-1.el7.centos         docker-main
docker-engine.x86_64      1.12.4-1.el7.centos         docker-main
docker-engine.x86_64      1.12.3-1.el7.centos         docker-main
docker-engine.x86_64      1.12.2-1.el7.centos         docker-main
docker-engine.x86_64      1.12.1-1.el7.centos         docker-main
docker-engine.x86_64      1.12.0-1.el7.centos         docker-main
docker-engine.x86_64      1.11.2-1.el7.centos         docker-main
docker-engine.x86_64      1.11.1-1.el7.centos         docker-main
docker-engine.x86_64      1.11.0-1.el7.centos         docker-main
docker-engine.x86_64      1.10.3-1.el7.centos         docker-main
docker-engine.x86_64      1.10.2-1.el7.centos         docker-main
docker-engine.x86_64      1.10.1-1.el7.centos         docker-main
docker-engine.x86_64      1.10.0-1.el7.centos         docker-main
 * base: mirrors.aliyun.com
Available Packages

由上述两段可以看出,阿里云镜像源中的docker安装包与docker官方提供的安装包名称并不相同,所以在使用yum安装的时候,很可能只出现找到第一段结果的情况,虽然配置了docker官方的源,却无法搜索到最新的docker版本。这里需要注意的是,如果想要使用docker官方的源中的安装包升级docker,那么要提供安装包的名字为docker-engine,这样就可以找到各个版本的docker了。

这里选取v1.13版本进行安装。

如果之前安装了docker,(一般来说使用的是centos源中的安装包),一定要将旧版本删除。因为本人之前安装的是v1.12版本,v1.13版较之前有很多变化,如果不删除的话,可能会有意想不到的问题出现。

删除v1.12版本docker

该版本的docker除了自身的docker软件包之外,还有两个依赖包,docker-common和container-linux,都需要删除

1
2
3
[root@localhost ~]# yum erase docker
[root@localhost ~]# yum erase docker-common
[root@localhost ~]# yum erase container-selinux

或者

1
2
3
[root@localhost ~]# yum remove docker
[root@localhost ~]# yum remove docker-common
[root@localhost ~]# yum remove container-selinux

最后安装v1.13版本docker

1
[root@localhost ~]# yum -y install docker-engine-1.13.1

启动docker并设置为开机自启

1
2
[root@localhost ~]# systemctl start docker
[root@localhost ~]# systemctl enable docker

可以通过命令查看当前docker版本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[root@localhost ~]# docker version
Client:
 Version:   1.13.1
 API version: 1.26
 Go version:  go1.7.5
 Git commit:  092cba3
 Built:    Wed Feb 8 06:38:28 2017
 OS/Arch:   linux/amd64
 
Server:
 Version:   1.13.1
 API version: 1.26 (minimum version 1.12)
 Go version:  go1.7.5
 Git commit:  092cba3
 Built:    Wed Feb 8 06:38:28 2017
 OS/Arch:   linux/amd64
 Experimental: false

以上就是本文的全部内容,希望对大家的学习有所帮助



文章分类
后端
版权声明:本站是系统测试站点,无实际运营。本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 XXXXXXo@163.com 举报,一经查实,本站将立刻删除。
相关推荐