前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >容器学习笔记之CentOS7安装Docker

容器学习笔记之CentOS7安装Docker

作者头像
Jetpropelledsnake21
发布2018-12-28 14:31:27
5400
发布2018-12-28 14:31:27
举报
文章被收录于专栏:JetpropelledSnakeJetpropelledSnake

0x00 概述

Docker从1.13版本之后采用时间线的方式作为版本号,分为社区版CE和企业版EE。

社区版是免费提供给个人开发者和小型团体使用的,企业版会提供额外的收费服务,比如经过官方测试认证过的基础设施、容器、插件等。

社区版按照stable和edge两种方式发布,每个季度更新stable版本,如17.06,17.09;每个月份更新edge版本,如17.09,17.10。

0x01 安装docker

1、Docker 要求 CentOS 系统的内核版本高于 3.10 ,查看本页面的前提条件来验证你的CentOS 版本是否支持 Docker 。

通过 uname -r 命令查看你当前的内核版本

代码语言:javascript
复制
 $ uname -r

2、使用 root 权限登录 Centos。确保 yum 包更新到最新。

代码语言:javascript
复制
$ sudo yum update

3、卸载旧版本(如果安装过旧版本的话)

代码语言:javascript
复制
$ sudo yum remove docker  docker-common docker-selinux docker-engine

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

代码语言:javascript
复制
$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2

5、设置yum源

代码语言:javascript
复制
$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

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

代码语言:javascript
复制
$ yum list docker-ce --showduplicates | sort -r

7、安装docker

代码语言:javascript
复制
$ sudo yum install docker-ce  #由于repo中默认只开启stable仓库,故这里安装的是最新稳定版17.12.0
$ sudo yum install <FQPN>  # 例如:sudo yum install docker-ce-17.12.0.ce

8、启动并加入开机启动

代码语言:javascript
复制
$ sudo systemctl start docker
$ sudo systemctl enable docker

9、验证安装是否成功(有client和service两部分表示docker安装启动都成功了)

代码语言:javascript
复制
$ docker version

0x02 注意问题

1、因为之前已经安装过旧版本的docker,在安装的时候报错如下:

代码语言:javascript
复制
Transaction check error:
  file /usr/bin/docker from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64
  file /usr/bin/docker-containerd from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64
  file /usr/bin/docker-containerd-shim from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64
  file /usr/bin/dockerd from install of docker-ce-17.12.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64

2、卸载旧版本的包

代码语言:javascript
复制
$ sudo yum erase docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64

3、再次安装docker

代码语言:javascript
复制
$ sudo yum install docker-ce

4、删除docker的方法:

代码语言:javascript
复制
yum remove docker docker-common docker-selinux docker-engine -y
/etc/systemd -name '*docker*' -exec rm -f {} ;
find /etc/systemd -name '*docker*' -exec rm -f {} \;
find /lib/systemd -name '*docker*' -exec rm -f {} \;

0x03 安装特定版本的Docker

查询可用版本

代码语言:javascript
复制
[root@bogon ~]# yum list docker-ce --showduplicates | sort -r

查询结果

代码语言:javascript
复制
 * updates: centos.ustc.edu.cn
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror, langpacks
 * extras: centos.ustc.edu.cn
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.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      

安装指定版本

代码语言:javascript
复制
[root@bogon ~]# sudo yum install docker-ce-17.12.0.ce-1.el7.centos

安装结果

代码语言:javascript
复制
Total                                                                                                       369 kB/s |  30 MB  00:01:24     
Retrieving key from https://download-stage.docker.com/linux/centos/gpg
Importing GPG key 0x621E9F35:
 Userid     : "Docker Release (CE rpm) <docker@docker.com>"
 Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
 From       : https://download-stage.docker.com/linux/centos/gpg
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 2:container-selinux-2.42-1.gitad8f0f7.el7.noarch                                                                         1/2 
  Installing : docker-ce-17.12.0.ce-1.el7.centos.x86_64                                                                                 2/2 
  Verifying  : 2:container-selinux-2.42-1.gitad8f0f7.el7.noarch                                                                         1/2 
  Verifying  : docker-ce-17.12.0.ce-1.el7.centos.x86_64                                                                                 2/2 

Installed:
  docker-ce.x86_64 0:17.12.0.ce-1.el7.centos                                                                                                

Dependency Installed:
  container-selinux.noarch 2:2.42-1.gitad8f0f7.el7                                                                                          

Complete!
[root@bogon ~]# 
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2018-12-24 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 0x00 概述
  • 0x01 安装docker
  • 0x02 注意问题
  • 0x03 安装特定版本的Docker
相关产品与服务
容器镜像服务
容器镜像服务(Tencent Container Registry,TCR)为您提供安全独享、高性能的容器镜像托管分发服务。您可同时在全球多个地域创建独享实例,以实现容器镜像的就近拉取,降低拉取时间,节约带宽成本。TCR 提供细颗粒度的权限管理及访问控制,保障您的数据安全。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档