一、安装步骤

前提条件

Docker运行在CentOS7上,要求系统64位、系统内核版本为3.10以上。

Docker是一个进程,一启动就两个进程,一个服务,一个守护进程。占用资源就非常少,启动速度非常

1,root账户登录,查看内核版本如下

[root@localhost ~]# uname -a
Linux localhost.qgc 3.10.0-862.11.6.el7.x86_64 #1 SMP Tue Aug 14 21:49:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

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

$ sudo yum remove docker  docker-common docker-selinux docker-engine

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

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

4、加软件源

[liu@localhost ~]$ sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo: yum-config-manager: command not found -----(表示依赖环境没有安装)

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

$ yum list docker-ce --showduplicates | sort -r

6:设置远程仓库

$sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

执行结果:
Loaded plugins: fastestmirror, langpacks
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

7、更新缓存

  1. yum makecache fast

8、安装docker

$ sudo yum install docker-ce

执行结果:
Loaded plugins: fastestmirror, langpacks
docker-ce-stable | 2.9 kB ::
docker-ce-stable/x86_64/primary_db | 4.8 kB ::
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 :17.03..ce-.el7.centos will be installed
--> Processing Dependency: docker-ce-selinux >= 17.03..ce-.el7.centos for package: docker-ce-17.03..ce-.el7.centos.x86_64
--> Processing Dependency: libcgroup for package: docker-ce-17.03..ce-.el7.centos.x86_64
--> Processing Dependency: libseccomp.so.()(64bit) for package: docker-ce-17.03..ce-.el7.centos.x86_64
--> Running transaction check
---> Package docker-ce-selinux.noarch :17.03..ce-.el7.centos will be installed
--> Processing Dependency: policycoreutils-python for package: docker-ce-selinux-17.03..ce-.el7.centos.noarch
---> Package libcgroup.x86_64 :0.41-.el7 will be installed
---> Package libseccomp.x86_64 :2.3.-.el7 will be installed
--> Running transaction check
---> Package policycoreutils-python.x86_64 :2.5-.el7_3 will be installed
--> Processing Dependency: setools-libs >= 3.3.- for package: policycoreutils-python-2.5-.el7_3.x86_64
--> Processing Dependency: libsemanage-python >= 2.5- for package: policycoreutils-python-2.5-.el7_3.x86_64
--> Processing Dependency: audit-libs-python >= 2.1.- for package: policycoreutils-python-2.5-.el7_3.x86_64
--> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-.el7_3.x86_64
--> Processing Dependency: libqpol.so.(VERS_1.)(64bit) for package: policycoreutils-python-2.5-.el7_3.x86_64
--> Processing Dependency: libqpol.so.(VERS_1.)(64bit) for package: policycoreutils-python-2.5-.el7_3.x86_64
--> Processing Dependency: libapol.so.(VERS_4.)(64bit) for package: policycoreutils-python-2.5-.el7_3.x86_64
--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-.el7_3.x86_64
--> Processing Dependency: libqpol.so.()(64bit) for package: policycoreutils-python-2.5-.el7_3.x86_64
--> Processing Dependency: libapol.so.()(64bit) for package: policycoreutils-python-2.5-.el7_3.x86_64
--> Running transaction check
---> Package audit-libs-python.x86_64 :2.6.-.el7_3. will be installed
---> Package checkpolicy.x86_64 :2.5-.el7 will be installed
---> Package libsemanage-python.x86_64 :2.5-5.1.el7_3 will be installed
---> Package python-IPy.noarch :0.75-.el7 will be installed
---> Package setools-libs.x86_64 :3.3.-1.1.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved =====================================================================================================================
Package Arch Version Repository Size
=====================================================================================================================
Installing:
docker-ce x86_64 17.03..ce-.el7.centos docker-ce-stable M
Installing for dependencies:
audit-libs-python x86_64 2.6.-.el7_3. update k
checkpolicy x86_64 2.5-.el7 base k
docker-ce-selinux noarch 17.03..ce-.el7.centos docker-ce-stable k
libcgroup x86_64 0.41-.el7 base k
libseccomp x86_64 2.3.-.el7 base k
libsemanage-python x86_64 2.5-5.1.el7_3 update k
policycoreutils-python x86_64 2.5-.el7_3 update k
python-IPy noarch 0.75-.el7 base k
setools-libs x86_64 3.3.-1.1.el7 base k Transaction Summary
=====================================================================================================================
Install Package (+ Dependent packages) Total download size: M
Installed size: M
Is this ok [y/d/N]: y
Downloading packages:
(/): audit-libs-python-2.6.-.el7_3..x86_64.rpm | kB ::
(/): checkpolicy-2.5-.el7.x86_64.rpm | kB ::
(/): libseccomp-2.3.-.el7.x86_64.rpm | kB ::
(/): libcgroup-0.41-.el7.x86_64.rpm | kB ::
(/): policycoreutils-python-2.5-.el7_3.x86_64.rpm | kB ::
(/): setools-libs-3.3.-1.1.el7.x86_64.rpm | kB ::
(/): libsemanage-python-2.5-5.1.el7_3.x86_64.rpm | kB ::
(/): python-IPy-0.75-.el7.noarch.rpm | kB ::
warning: /var/cache/yum/x86_64//docker-ce-stable/packages/docker-ce-selinux-17.03..ce-.el7.centos.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY
Public key for docker-ce-selinux-17.03..ce-.el7.centos.noarch.rpm is not installed
(/): docker-ce-selinux-17.03..ce-.el7.centos.noarch.rpm | kB ::
(/): docker-ce-17.03..ce-.el7.centos.x86_64.rpm | MB ::
---------------------------------------------------------------------------------------------------------------------
Total MB/s | MB ::
Retrieving key from https://download.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.docker.com/linux/centos/gpg
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libcgroup-0.41-.el7.x86_64 /
Installing : setools-libs-3.3.-1.1.el7.x86_64 /
Installing : checkpolicy-2.5-.el7.x86_64 /
Installing : libsemanage-python-2.5-5.1.el7_3.x86_64 /
Installing : audit-libs-python-2.6.-.el7_3..x86_64 /
Installing : python-IPy-0.75-.el7.noarch /
Installing : policycoreutils-python-2.5-.el7_3.x86_64 /
Installing : docker-ce-selinux-17.03..ce-.el7.centos.noarch /
setsebool: SELinux is disabled.
libsemanage.semanage_direct_install_info: Overriding docker module at lower priority with module at priority .
Installing : libseccomp-2.3.-.el7.x86_64 /
Installing : docker-ce-17.03..ce-.el7.centos.x86_64 /
Verifying : libseccomp-2.3.-.el7.x86_64 /
Verifying : python-IPy-0.75-.el7.noarch /
Verifying : audit-libs-python-2.6.-.el7_3..x86_64 /
Verifying : libsemanage-python-2.5-5.1.el7_3.x86_64 /
Verifying : docker-ce-selinux-17.03..ce-.el7.centos.noarch /
Verifying : libcgroup-0.41-.el7.x86_64 /
Verifying : policycoreutils-python-2.5-.el7_3.x86_64 /
Verifying : docker-ce-17.03..ce-.el7.centos.x86_64 /
Verifying : checkpolicy-2.5-.el7.x86_64 /
Verifying : setools-libs-3.3.-1.1.el7.x86_64 / Installed:
docker-ce.x86_64 :17.03..ce-.el7.centos Dependency Installed:
audit-libs-python.x86_64 :2.6.-.el7_3. checkpolicy.x86_64 :2.5-.el7
docker-ce-selinux.noarch :17.03..ce-.el7.centos libcgroup.x86_64 :0.41-.el7
libseccomp.x86_64 :2.3.-.el7 libsemanage-python.x86_64 :2.5-5.1.el7_3
policycoreutils-python.x86_64 :2.5-.el7_3 python-IPy.noarch :0.75-.el7
setools-libs.x86_64 :3.3.-1.1.el7 Complete!

九、启动docker并加入开机启动

$ sudo systemctl start docker
$ sudo systemctl enable docker 或者(推荐上面的)
$ sudo service docker start
service docker start #启动docker
chkconfig docker on #加入开机启动

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

docker version


十一、测试容器

   sudo docker run hello-world   #基于hello-world镜像启动一个容器,如果本地没有镜像会从公网拉取过来,这次做为测试用

  sudo docker info #查看信息

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. To generate this message, Docker took the following steps:
. The Docker client contacted the Docker daemon.
. The Docker daemon pulled the "hello-world" image from the Docker Hub.
. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal. To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID:
https://cloud.docker.com/ For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/

  

二、问题

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

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、卸载旧版本的包

$ sudo yum erase docker-common-2:1.12.6-68.gitec8512b.el7.centos.x86_64

3、再次安装docker

$ sudo yum install docker-ce

一、docker安装CentOS7的更多相关文章

  1. Docker安装 - CentOS7环境

    Docker安装 - CentOS7环境 安装Docker 我是虚拟机装的Centos7,linux 3.10 内核,docker官方说至少3.8以上,建议3.10以上(ubuntu下要linux内核 ...

  2. Docker 安装(centos7下)

    下面链接为官方的安装方法(官方的是最好的): https://docs.docker.com/install/linux/docker-ce/centos/#upgrade-docker-after- ...

  3. docker 安装centos7并SSH远程连接

    1.安装centos7 镜像 1.搜索并拉取centos镜像(默认最新镜像) docker search centos docker pull centos 2.建立本机对应docker-centos ...

  4. win系统下之docker安装centos7镜像

    1)    拉取镜像 输入命令docker pull centos:7 从仓库拉取centos7的镜像 2)    查看本地镜像 命令:docker images 可以查看已经把centos的镜像拉取 ...

  5. Docker安装CentOS7

    1. 拉取镜像 docker pull centos:centos7 2. 启动镜像创建容器 docker run -d -p 36622:22 -p 36680:80 --name centos7- ...

  6. docker安装centos7镜像

    拉取centos7镜像[root@localhost ~]# docker pull centos:71启动镜像centos7,如果不指定 /bin/bash,容器运行后会自动停止[root@loca ...

  7. docker安装CentOS7及JNI使用相关过程记录

    docker pull centos:centos7(拉取镜像) docker run -itd --name centos-test centos:centos7 (运行容器) docker exe ...

  8. docker安装-centos7

    操作系统要求 要安装Docker,您需要64位版本的CentOS 7.步骤:   卸载旧版本 Docker的旧版本被称为docker或docker-engine . 如果这些已安装,请卸载它们以及关联 ...

  9. linux上docker安装centos7.2

    1.安装 docker pull centos:7.2.1511 2.启动镜像 docker run -d -i -t <IMAGE ID> /bin/bash 3.进入容器 docker ...

随机推荐

  1. Visual Studio 最新插件

    Resharper 最新版本下载 https://www.jetbrains.com/resharper/ 破解方法 安装完成后,打开vs  弹出注册窗口选择Activate>License S ...

  2. 关于MQ的几件小事(四)如何保证消息不丢失

    1.mq原则 数据不能多,也不能少,不能多是说消息不能重复消费,这个我们上一节已解决:不能少,就是说不能丢失数据.如果mq传递的是非常核心的消息,支撑核心的业务,那么这种场景是一定不能丢失数据的. 2 ...

  3. ndk-build 修改输出so位置 (change ndk-build output so lib file path )

    期望的目录结构: Folder --- | --- build.bat | --- Source | --- All sources codes *.cpp *.h | --- Android --- ...

  4. 用js原生加jquery实现下拉跳转至商品详情页,上拉回到商品简介

    在做一个商城的项目时,做到商品详情页的时候需要实现这种下拉跳转到商品详情页加载许多图片,上拉回到商品简介的效果,并且需要用户在滑动时有一种费力的感觉.最初是通过iscroll插件实现的,但这个插件在使 ...

  5. leetcode-64. 最小路径和 · vector + DP

    题面 Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right wh ...

  6. 【vue开发】vue插件的install方法

    MyPlugin.install = function (Vue, options) { // 1. 添加全局方法或属性 Vue.myGlobalMethod = function () { // 逻 ...

  7. 成为一个高级java架构师所需要具备那些技能呢?

    一.什么是架构师 所谓架构师,思考的是全局的东西,是如何组织你的系统,以达到业务要求,性能要求,具备可扩展性(scalability),可拓展性(extendability),前后兼容性等.可能涉及到 ...

  8. Java学习第二天之Java程序的基本规则

    一.Java程序的组织形式 Java程序是一种纯粹的面向对象的程序设计语言,因此Java程序必须以类(即class)的形式存在,类(class)是Java程序的最小程序单位.Java程序不允许可执行性 ...

  9. AWD模式搅屎模式

    AWD模式搅屎模式 ###0x01 出题思路 ####1:题目类型 1-出题人自己写的cms,为了恶心然后加个so. 2-常见或者不常见的cms. 3-一些框架漏洞,比如ph师傅挖的CI这种 #### ...

  10. k2系列-开发篇

    上一篇讲到K2安装的具体操作,本篇我们具体讲一下在VS环境下如何开发K2工作流. 常用工具控件说明: 节点关联线:流程各节点之间的关联线 客户端节点:流程的基本元素 服务器端节点:流程的完成标识节点 ...