报错:Error: docker-ce-selinux conflicts with 2:container-selinux-2.12-2.gite7096ce.el7.noarch

转载:http://abloz.com/tech/2017/06/06/centos7-docker-installation/

概述

本文是centos7上安装docker-ce社区版的最新稳定版的实录.

docker-ce最新稳定版需要linux kernel 大于3.10.

可以用如下的程序来检查兼容性.

curl https://raw.githubusercontent.com/docker/docker/master/contrib/check-config.sh > check-config.sh
bash ./check-config.sh

对其他操作系统和版本,可以参考官方文档.

安装相关依赖

yum-utils 提供 yum-config-manager 工具, devicemapper存储驱动依赖 device-mapper-persistent-data 和 lvm2.

[zhouhh@mainServer ~]$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2

配置版本镜像库

季度更新的稳定stable版和月度更新的edge版

[zhouhh@mainServer ~]$ sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
[zhouhh@mainServer ~]$ sudo yum-config-manager --enable docker-ce-edge

这会在/etc/添加 /etc/yum.repos.d/docker-ce.repo 内容类似:

[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg
[docker-ce-edge]
name=Docker CE Edge - $basearch
baseurl=https://download.docker.com/linux/centos/7/$basearch/edge
enabled=1
gpgcheck=1
gpgkey=https://download.docker.com/linux/centos/gpg

由于docker.com服务器下载很慢,所以改为国内镜像.

新建 /etc/yum.repos.d/docker.repo,内容为

[dockerrepo]
name=Docker Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/docker/yum/repo/centos7
enabled=1
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/docker/yum/gpg

执行

[zhouhh@mainServer yum.repos.d]$ sudo yum makecache

如需禁止edge版本, 可以执行下面的命令

[zhouhh@mainServer ~]$ sudo yum-config-manager --disable docker-ce-edge

安装docker

[zhouhh@mainServer ~]$ sudo yum makecache fast

[zhouhh@mainServer ~]$ sudo yum install docker-ce
Error: docker-ce conflicts with 2:docker-1.12.6-28.git1398f24.el7.centos.x86_64
Error: docker-ce-selinux conflicts with 2:container-selinux-2.12-2.gite7096ce.el7.noarch

出现冲突, 原因是直接安装过docker.

[zhouhh@mainServer ~]$ yum list docker

Installed Packages
docker.x86_64 2:1.12.6-28.git1398f24.el7.centos @extras
[zhouhh@mainServer ~]$ sudo yum erase docker.x86_64
Removed:
docker.x86_64 2:1.12.6-28.git1398f24.el7.centos
[zhouhh@mainServer ~]$ sudo yum list container-selinux-2.12-2.gite7096ce.el7.noarch [zhouhh@mainServer ~]$ sudo yum erase container-selinux.noarch

再安装:

[zhouhh@mainServer ~]$ sudo yum install docker-ce
Loaded plugins: fastestmirror, langpacks
Installing:
docker-ce x86_64 17.05.0.ce-1.el7.centos docker-ce-edge 19 M
Installing for dependencies:
docker-ce-selinux noarch 17.05.0.ce-1.el7.centos docker-ce-edge 28 k [Errno 12] Timeout on https://download.docker.com/linux/centos/7/x86_64/edge/Packages/docker-ce-17.05.0.ce-1.el7.centos.x86_64.rpm Transaction check error:
file /usr/bin/docker from install of docker-ce-17.05.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-28.git1398f24.el7.centos.x86_64
file /usr/bin/docker-containerd from install of docker-ce-17.05.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-28.git1398f24.el7.centos.x86_64
file /usr/bin/docker-containerd-shim from install of docker-ce-17.05.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-28.git1398f24.el7.centos.x86_64
file /usr/bin/dockerd from install of docker-ce-17.05.0.ce-1.el7.centos.x86_64 conflicts with file from package docker-common-2:1.12.6-28.git1398f24.el7.centos.x86_64 Error Summary

如果生产系统需要稳定版本, 需要 yum list 进行查询. 但yum list只会显示二进制包, 加上.x86_64会显示包含源码包的全部的包. sort -r会按版本倒序排序.

[zhouhh@mainServer ~]$ yum list docker-ce.x86_64  --showduplicates |sort -r
* updates: mirrors.tuna.tsinghua.edu.cn
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror, langpacks
* extras: mirror.bit.edu.cn
docker-ce.x86_64 17.05.0.ce-1.el7.centos docker-ce-edge
docker-ce.x86_64 17.04.0.ce-1.el7.centos docker-ce-edge
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: mirror.bit.edu.cn

第二列是版本号. el7表示centos7. 第三列是库名.

安装指定版本: sudo yum install docker-ce-

安装稳定版本:


[zhouhh@mainServer ~]$ sudo yum install docker-ce-17.03.1.ce-1.el7.centos
Installed:
docker-ce.x86_64 0:17.03.1.ce-1.el7.centos Dependency Installed:
docker-ce-selinux.noarch 0:17.05.0.ce-1.el7.centos Complete!

# 删除老版本docker

如果需要删除老的版本, 可以用如下的命令查询和删除. 老版本docker名字叫docker或docker-engine. 新版本社区版叫docker-ce, 企业版是docker-ee

[zhouhh@mainServer ~]$ yum list installed | grep docker
docker-client.x86_64 2:1.12.6-28.git1398f24.el7.centos
docker-common.x86_64 2:1.12.6-28.git1398f24.el7.centos
[zhouhh@mainServer ~]$ sudo yum erase -y docker-client.x86_64
[zhouhh@mainServer ~]$ sudo yum erase -y docker-common.x86_64 [zhouhh@mainServer ~]$ sudo yum remove docker \
docker-common \
container-selinux \
docker-selinux \
docker-engine

删除docker ce版和镜像

[zhouhh@mainServer ~]$ sudo yum remove docker-ce
[zhouhh@mainServer ~]$ sudo rm -rf /var/lib/docker

可能还需要移除devicemapper, 重新格式化相关块设备.

[zhouhh@mainServer ~]$ sudo mkdir /etc/docker
[zhouhh@mainServer ~]$ sudo vi /etc/docker/daemon.json
{
"storage-driver": "devicemapper"
}

对生产系统, 需要使用direct-lvm模式,需准备块设备,参考: devicemapper storage driver guide

启动测试docker

Hello world的镜像启动后会打印”Hello from Docker!”然后退出.

[zhouhh@mainServer ~]$ sudo systemctl start docker
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
78445dd45222: Pull complete
Digest: sha256:c5515758d4c5e1e838e9cd307f6c6a0d620b5e07e6f927b07d05f6d12a1ac8d7
Status: Downloaded newer image for hello-world:latest Hello from Docker!
This message shows that your installation appears to be working correctly.

非root用户启动docker

[zhouhh@mainServer ~]$ sudo groupadd docker
[zhouhh@mainServer ~]$ sudo usermod -aG docker $USER
[zhouhh@mainServer ~]$ exit
logout
[zhouhh@mainServer ~]$ docker run hello-world Hello from Docker!
This message shows that your installation appears to be working correctly.

设置自启动

大部分最新的linux发行版(RHEL, CentOS, Fedora, Ubuntu 16.04 以上), 都用sytemd来管理启动.

[zhouhh@mainServer ~]$ sudo systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

禁止自启动

[zhouhh@mainServer ~]$ sudo systemctl disable docker

参考

Get Docker for CentOS


如非注明转载, 均为原创. 本站遵循知识共享CC协议,转载请注明来源

centos7上安装docker-ce社区版的更多相关文章

  1. Ubuntu 安装 Docker CE(社区版)

    参考自 https://yeasy.gitbooks.io/docker_practice/install/ubuntu.html#ubuntu-1604- docker-io 是以前早期的版本,版本 ...

  2. 在centos7上安装Docker CE

    Docker CE的基本安装 https://docs.docker.com/engine/installation/linux/docker-ce/centos/ 一.系统要求 1.安装Docker ...

  3. centos7上安装docker社区版

    container(容器) docker(集装箱) 容器的优点 1. 启动速度快 2. 节省资源 3. 兼容性高 保证机器正常上网 #ping www.baidu.com CPU需要支持虚拟化 # g ...

  4. Centos7上安装docker (转)

    Centos7上安装docker Docker从1.13版本之后采用时间线的方式作为版本号,分为社区版CE和企业版EE. 社区版是免费提供给个人开发者和小型团体使用的,企业版会提供额外的收费服务,比如 ...

  5. debian上安装docker ce

    在Debian9上安装Docker CE 使用从包中安装的方式 Docker是一个开源的容器引擎,它有助于更快地交付产品.Docker可将应用程序和基础设施层隔离,并且将基础设施当作程序一样进行管理. ...

  6. centos 7 安装 Docker Engine-CentOS 社区版

    获取Docker Engine-CentOS社区: https://docs.docker.com/install/linux/docker-ce/centos/ 1.操作系统要求 1.1 要安装 D ...

  7. centos7 下安装Docker CE

    前提条件 操作系统要求 要保证centos-extrasrepository开启(enabled).默认处于开启状态. 推荐使用overlay2存储驱动 卸载老版本 $ sudo yum remove ...

  8. Ubuntu18.04上安装Docker CE

    建立 REPOSITORY 1.更新索引包 更新 /etc/apt/sources.list 和 /etc/apt/sources.list.d 中列出的源的地址,这样才能获取到最新的软件包 sudo ...

  9. Centos7上安装docker

    Docker从1.13版本之后采用时间线的方式作为版本号,分为社区版CE和企业版EE. 社区版是免费提供给个人开发者和小型团体使用的,企业版会提供额外的收费服务,比如经过官方测试认证过的基础设施.容器 ...

  10. Centos7上安装docker (新手版本)

    1首先要有一个安装好的Centos7 2打开终端,输入一下命令(自动安装最新版本) curl -fsSL https://get.docker.com | bash -s docker --mirro ...

随机推荐

  1. Java+Selenium3自动化测试框架设计系列--href="javascript:void(0)"如何获得元素定位

    经过前面两篇文章的铺 垫,我们这篇介绍,webdriver如何处理,一个浏览器上多个窗口之间切换的问题.我们先脑补这样一个测试场景,你在页面A点击一个连接,会在新的 tab窗口打开页面B,这个时候,你 ...

  2. linux实验-基本指令1

    1.root帐号登录,查看/tmp目录,如果/tmp目录下没有子目录myshare,则建立该目录. 2.创建帐号testuser. 3.把myshare目录及其目录下的所有文件和子目录的拥有者该为te ...

  3. TCD产品技术参考资料

    1.Willis环 https://en.wikipedia.org/wiki/Circle_of_Willis 2.TCD仿真软件 http://www.transcranial.com/index ...

  4. 【算法】 string 转 int

    [算法] string 转 int 遇到的一道面试题, 当时只写了个思路, 现给出具体实现 ,算是一种比较笨的实现方式 public class StringToInt { /// <summa ...

  5. 使用PSSH批量操作Linux服务器

    简介 服务器多了,有一个问题就是如何批量快速操作多台服务器,在网上搜到了PSSH工具,试用了一下发现挺好用,推荐给大家. pssh是一个python编写的可以在多台服务器上执行命令的轻量级管理工具,同 ...

  6. Google序列化库FlatBuffers 1.1发布,及与protobuf的比较

    个人总结: FlatBuffer相对于Protobuffer来讲,优势如下: 1. 由于省去了编解码的过程,所以从速度上快于Protobuffer,个人测试结果100w次编解码,编码上FlatBuff ...

  7. Wireshark lua dissector 对TCP消息包合并分析

    应用程序发送的数据报都是流式的,IP不保证同一个一个应用数据包会被抓包后在同一个IP数据包中,因此对于使用自制dissector的时候需要考虑这种情况. Lua Dissector相关资料可以见:ht ...

  8. Jmeter和Charles下载文件

    有时候我们jmeter做自动化测试是会遇到文件上传和文件下载的接口,这里我将接结合Charles来Jmeter 文件下载进行讲解 一.用Charles抓包分析文件下载接口 1.1.业务中文件下载链接如 ...

  9. POSTMAN——环境变量

    打开Manage Environment 设置几个自己的环境变量 可以在此看到设置的环境变量 在URL栏填写变量名,这个变量对应着百度的网址 send后可以查看回显 接下来设置全局变量,点开globa ...

  10. Spring实战第八章学习笔记————使用Spring Web Flow

    Spring实战第八章学习笔记----使用Spring Web Flow Spring Web Flow是一个Web框架,它适用于元素按规定流程运行的程序. 其实我们可以使用任何WEB框架写流程化的应 ...