Docker容器技术基础入门篇

摘要:
从这个角度来讲,Docker是什么东西呢?容器时Linux内核中的技术,Docker只是把容器技术的使用用它的简化得以普及而已。7˃.进入Docker技术时代  2008年,Docker公司凭借与公司同名的容器技术通过dotCloud登上了舞台。Docker技术带来了很多新的概念和工具,包括可运行和构建新的分层镜像的简单命令行界面、服务器守护进程、含有预构建容器镜像的库以及注册表服务器概念。

Docker容器技术基础入门篇

作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

一.容器(Container)

1>.什么是容器

容器是一种基础工具;泛指任何可以用于容纳其它物品的工具,可以部分或完全封闭,被用于容纳,存储,运输物品;物体可以被放置在容器中,而容器则可以保护内容物。
  人类使用容器的历史至少有十万年,甚至可能有数百万的历史。

2>.容器的类型

瓶:
    指口部比腹部窄小,颈长的容器。
  罐:
    指那些开口较大,一般为近圆筒形的器皿。
  箱:
    通常是立方体或圆柱体。形状固定。
  蓝:
    以条形物编织而成。
  桶:
    一种圆柱形的容器。
  袋:
    柔性材料制成的容器,形状会受内容物而变化。
  翁:
    通常是指陶制,口小肚大的容器。
  碗:
    用来盛载食物的容器。
  柜:
    指由一个盒组成的家俱。
  鞘:
    用于装载刀刃的容器。

3>.什么是 Linux 容器?

Linux容器是与系统其他部分隔离开的一系列进程。运行这些进程所需的所有文件都由另一个镜像提供,这意味着从开发到测试再到生产的整个过程中,Linux 容器都具有可移植性和一致性。因而,相对于依赖重复传统测试环境的开发渠道,容器的运行速度要快得多。
  假设您在开发一个应用。您使用的是一台笔记本电脑,而且您的开发环境具有特定的配置。其他开发人员身处的环境配置可能稍有不同。您正在开发的应用不止依赖于您当前的配置,还需要某些特定的库、依赖项和文件。与此同时,您的企业还拥有标准化的开发和生产环境,有着自己的配置和一系列支持文件。您希望尽可能多在本地模拟这些环境,而不产生重新创建服务器环境的开销。因此,您要如何确保应用能够在这些环境中运行和通过质量检测,并且在部署过程中不出现令人头疼的问题,也无需重新编写代码和进行故障修复?答案就是使用容器。

Docker容器技术基础入门篇第1张

  容器可以确保您的应用拥有必需的库、依赖项和文件,让您可以在生产中自如地迁移这些应用,无需担心会出现任何负面影响。实际上,您可以将容器镜像中的内容,视为 Linux 发行版的一个安装实例,因为其中完整包含 RPM 软件包、配置文件等内容。但是,安装容器镜像发行版,要比安装新的操作系统副本容易得多。这样可以避免危机,做到皆大欢喜。详情请参考:https://www.redhat.com/zh/topics/containers/whats-a-linux-container。

4>.容器不就是虚拟化吗?

不完全如此。更确切的说法应该是:两者为互补关系。我们用一种简单方式来思考一下:
    主机级虚拟化:  
虚拟化使得您的操作系统(Windows 或 Linux)可同时在单个硬件系统上运行。即需要虚拟整个完整物理硬件平台,典型代表就是我们常见的“VMware Workstation”。   
容器级虚拟化:
容器则可共享同一个操作系统内核,将应用进程与系统其他部分隔离开。例如:ARM Linux 系统运行 ARM Linux 容器,x86 Linux 系统运行 x86 Linux 容器,x86 Windows 系统运行 x86 Windows 容器。Linux 容器具有极佳的可移植性,但前提是它们必须与底层系统兼容。

Docker容器技术基础入门篇第2张

这意味着什么?虚拟化会使用虚拟机监控程序模拟硬件,从而使多个操作系统能够并行运行。但这不如容器轻便。事实上,在仅拥有容量有限的有限资源时,您需要能够可以进行密集部署的轻量级应用。Linux 容器在本机操作系统上运行,与所有容器中共享该操作系统,因此应用和服务能够保持轻巧,并行化快速运行。
  Linux 容器是我们开发、部署和管理应用方式的又一次飞跃。Linux 容器镜像提供了可移植性和版本控制,确保能够在开发人员的笔记本电脑上运行的应用,同样也能在生产环境中正常运行。相较于虚拟机,Linux 容器在运行时所占用的资源更少,使用的是标准接口(启动、停止、环境变量等),并会与应用隔离开;此外,作为(包含多个容器)大型应用的一部分时更加易于管理,而且这些多容器应用可以跨多个云环境进行编排。

5>.容器简史

容器并非起源于 Linux,但开源世界的最精彩之处就在于借鉴、修改和改进,容器也不例外。
  我们现在称为容器技术的概念最初出现在 2000 年,时称 FreeBSD jail,这种技术可将 FreeBSD 系统分区为多个子系统(也称为 Jail)。Jail 是作为安全环境而开发的,系统管理员可与企业内部或外部的多个用户共享这些 Jail。Jail 的目的是让进程在经过修改的 chroot 环境中创建,而不会脱离和影响整个系统 — 在 chroot环境中,对文件系统、网络和用户的访问都实现了虚拟化。尽管 Jail 在实施方面存在局限性,但最终人们找到了脱离这种隔离环境的方法。但这个概念非常有吸引力。
  2001 年,通过 Jacques Gélinas 的 VServer 项目,隔离环境的实施进入了 Linux 领域。正如 Gélinas 所说,这项工作的目的是“在高度独立且安全的单一环境中运行多个通用 Linux 服务器 [sic]。” 在完成了这项针对 Linux 中多个受控制用户空间的基础性工作后,Linux 容器开始逐渐成形并最终发展成了现在的模样。

Docker容器技术基础入门篇第3张

6>.容器变得具有实用性

很快,更多技术结合进来,让这种隔离方法从构想变为现实。控制组 (cgroups) 是一项内核功能,能够控制和限制一个进程或多组进程的资源使用。而 systemd 初始化系统可设置用户空间,并且管理它们的进程,cgroups 使用该系统来更严密地控制这些隔离进程。这两种技术在增加对 Linux 的整体控制的同时,也成为了保持环境隔离的重要框架。
  内核命名空间的改进,推动了容器的进一步发展。利用内核命名空间,从进程 ID 到网络名称,一切都可在 Linux 内核中实现虚拟化。新增的用户命名空间“使得用户和组 ID 可以按命名空间进行映射。对于容器而言,这意味着用户和组可以在容器内部拥有执行某些操作的特权,而在容器外部则没有这种特权。”Linux 容器项目 (LXC) 还添加了用户急需的一些工具、模板、库和语言绑定,从而推动了这些进步,进而改善了使用容器的用户体验。
虽然 LXC 使得用户能够通过简单的命令行界面轻松地启动使用容器,但是和我们过去使用的虚拟机来讲,它的复杂程度并没有多大降低,而且其隔离性依旧没有虚拟机好。
LXC最大的好处就是在性能和资源上有所节约,但是在大规模容器使用上LXC依然没有找到很好的突破口,于是后来就出现了Docker。从这个角度来讲,Docker是什么东西呢?它是LXC的增强版,自己也不是容器,而是容器的前端应用工具。容器时Linux内核中的技术,Docker只是把容器技术的使用用它的简化得以普及而已。

7>.进入 Docker 技术时代

  2008年,Docker 公司凭借与公司同名的容器技术通过dotCloud登上了舞台。Docker 技术带来了很多新的概念和工具,包括可运行和构建新的分层镜像的简单命令行界面、服务器守护进程、含有预构建容器镜像的库以及注册表服务器概念。通过综合运用这些技术,用户可以快速构建新的分层容器,并轻松地与他人共享这些容器。
  红帽意识到了在这个全新的生态系统中协作能够产生的巨大力量,因而在我们的 OpenShift 容器平台中采用了底层技术。为了避免如此重要的技术被单个供应商掌控,Docker Inc. 向社区主导型开源项目提供了很多底层组件(runc 源自开放容器计划,containerd 已移交给 CNCF)。
  我们可通过三个主要标准,来确保各种容器技术间的互操作性,即 OCI 镜像、分发和运行时规范。通过遵循上述规范,社区项目、商用产品和云技术提供商可以构建可互操作的容器技术(可将您自行构建的镜像,推送至云技术提供商的注册表服务器——完成这一操作后,镜像才能正常工作)。当前,红帽和 Docker 等公司都是开放容器计划(OCI)的成员,致力于实现容器技术的开放行业标准化。

Docker容器技术基础入门篇第4张

二.Linux Namespaces种类

从内核版本4.10开始,有7种命名空间。命名空间功能在所有类型中都是相同的:每个进程都与命名空间相关联,并且只能查看或使用与该命名空间关联的资源,以及适用的后代命名空间。这样,每个进程(或其组)可以具有关于资源的唯一视图。隔离哪个资源取决于为给定进程组创建的命名空间的类型。以下内容参考自:https://en.wikipedia.org/wiki/Linux_namespaces

1>.装载(Mount ,简称:mnt)
  挂载命名空间控制挂载点。创建后,当前mount命名空间中的挂载将复制到新的命名空间,但之后创建的挂载点不会在命名空间之间传播(使用共享子树,可以在命名空间之间传播挂载点)。
  用于创建此类型的新命名空间的克隆标志是CLONE_NEWNS -“NEW NameSpace”的缩写。这个术语不是描述性的(因为它没有说明要创建哪种命名空间),因为mount命名空间是第一种命名空间,设计者没有预料到会有其他命名空间。
  系统调用参数为:"CLONE_NEWNS",从内核版本"2.4.19"就开始支持。
2>.进程ID(Process ID 简称:pid)
  PID命名空间为进程提供来自其他命名空间的独立进程ID(PID)集。PID名称空间是嵌套的,这意味着在创建新进程时,它将为每个名称空间从其当前名称空间到初始PID名称空间具有PID。因此,初始PID命名空间能够查看所有进程,尽管具有与其他命名空间不同的PID将看到进程。
  在PID命名空间中创建的第一个进程被分配了进程ID号1,并且接收了大多数与正常init进程相同的特殊处理,最值得注意的是命名空间中的孤立进程被附加到它。这也意味着此PID 1进程的终止将立即终止其PID命名空间和任何后代中的所有进程。
  系统调用参数为:"CLONE_NEWPID",从内核版本"2.6.24"就开始支持。
3>.网络(Network 简称:net)
  网络命名空间虚拟化网络堆栈。在创建时,网络命名空间仅包含环回接口。
  每个网络接口(物理或虚拟)都存在于1个命名空间中,可以在命名空间之间移动。
  每个命名空间都有一组私有IP地址,自己的路由表,套接字列表,连接跟踪表,防火墙和其他与网络相关的资源。
  销毁网络命名空间会破坏其中的任何虚拟接口,并将其中的任何物理接口移回初始网络命名空间。
  系统调用参数为:"CLONE_NEWNET",从内核版本"2.6.29"就开始支持。
4>.进程间通信(Interprocess Communication 简称:ipc)
  IPC名称空间将进程与SysV样式的进程间通信隔离开来。这可以防止不同IPC名称空间中的进程使用例如SHM系列函数在两个进程之间建立一系列共享内存。相反,每个进程将能够为共享内存区域使用相同的标识符,并生成两个这样的不同区域。同一机器之间进程通信的方式有很多,比如消息队列(message queues),共享内存(shared memory)等等。跨主机之间的通信我们称之为套接字通信,也是我们应用最多的!
  系统调用参数为:"CLONE_NEWIPC",从内核版本"2.6.19"就开始支持。
5>.悉尼科技大学(简称:UTS)
  UTS名称空间允许单个系统看起来具有不同进程的主机名和域名。
  系统调用参数为:"CLONE_NEWUTS",从内核版本"2.6.19"就开始支持。
6>.用户ID(User ID 简称:user)
  用户命名空间是一种在多组进程中提供权限隔离和用户标识隔离的功能。通过管理帮助,可以构建具有看似管理权限的容器,而无需实际提升用户进程的权限。与PID命名空间一样,用户命名空间是嵌套的,并且每个新用户命名空间都被视为创建它的用户命名空间的子节点。
  用户命名空间包含一个映射表,用于将用户ID从容器的角度转换为系统的角度。例如,这允许root用户在容器中具有用户id 0,但实际上系统将其视为用户ID 1,400,000以进行所有权检查。类似的表用于组ID映射和所有权检查。
  为了促进管理操作的权限隔离,每个命名空间类型在创建时基于活动用户命名空间被用户命名空间认为。在相应的用户命名空间中具有管理权限的用户将被允许在该其他命名空间类型中执行管理操作。例如,如果进程具有更改网络接口的IP地址的管理权限,则只要其自己的用户命名空间与拥有网络命名空间的用户命名空间(或其祖先)相同,它就可以这样做。因此,初始用户命名空间具有对系统中所有命名空间类型的管理控制。
  系统调用参数为:"CLONE_NEWUSER",从内核版本"3.8"就开始支持,因此CentOS 6.x 天然就排除在外了,因为CentOS 6.x 使用的是2.6.x的内核。
7>.对照组(也叫控制组,英文名称为:Control group 简称:cgroup)
  cgroup命名空间类型隐藏了进程所属的控制组的标识。
  在这样的命名空间中的进程,检查任何进程所属的控制组,将看到实际上相对于在创建时设置的控制组的路径,隐藏其真实的控制组位置和身份。
  此命名空间类型自Linux 4.6以来就已存在。
  对cgroups来讲,它无非就是把系统级的资源分成多个组,然后把每一个组内的资源量分配到特定的用户空间的进程上去的事情。它包括以下资源:
    blkio:
块设备IO     cpu:
分配CPU     cpuacct:
CPU资源使用报告     cpuset:
多处理平台上的CPU集合     devices:
设备访问     freezzer:
挂在或恢复任务     memory:
内存用量及报告     perf_event:
对cgroup中的任务进行统一性能测试     net_cls:
cgroup中的任务创建的数据报告的类别标识符

三.Docker简史

1>.什么是Docker

LXC最大的好处就是在性能和资源上有所节约,但是在大规模容器使用上LXC依然没有找到很好的突破口,于是后来就出现了Docker。从这个角度来讲,Docker是什么东西呢?它是LXC的增强版,自己也不是容器,而是容器的前端应用工具。容器时Linux内核中的技术,Docker只是把容器技术的使用用它的简化得以普及而已。
  我们知道LXC在大规模创建容器很难,或者在另一台主机克隆一个和当前主机容器一模一样的容器也很难。因此Docker就在这方面找解决方案了。
  早期的Docker就是一个LXC的二次封装发行版(后来Docker公司研发了libcontainer来替代LXC,不过此时Docker已被CNCF挟持了,当然容器的话语权依旧归Docker公司,这并不是说CNCF组织没有能力Docker的标准,只不过他们真那样做就太欺负Docker公司了,后来Docker又转型到runC)。功能上是这样实现的:利用LXC做容器管理引擎,但是在创建容器用户空间时不在用LXC的模板现场安装生成容器,而是实事先通过一种镜像技术(类似于KVM镜像启动),把一个操作系统用户空间所要用到的所有组件事先准备编排好打包成一个文件,这个文件Docker称之为镜像文件。
  “Docker” 一词指代了多个概念,包括开源社区项目、开源项目使用的工具、主导支持此类项目的公司 Docker Inc. 以及该公司官方支持的工具。技术产品和公司使用同一名称,的确让人有点困惑。我们来简单说明一下:
    IT 软件中的 “Docker” 是指容器化技术,用于创建和使用 Linux 容器。
    
    开源 Docker 社区致力于改进这类技术,并免费提供给所有用户,互利共赢。
    
    Docker Inc. 公司凭借 Docker 社区产品起家,它主要负责提升社区版本的安全性,并将技术进步与广大技术社区分享。此外,它还专门对这些技术产品进行完善和安全加固,服务于企业客户。
    
    借助 Docker,您可将容器当做轻巧、模块化的虚拟机使用。同时,您还将获得高度的灵活性,从而可以高效地创建、部署和复制容器,并能将其从一个环境顺利迁移至另一个环境。详情请参考:https://www.redhat.com/zh/topics/containers/what-is-docker。
    

2>.Docker容器编排技术

  Docker 在最初设计时只关注了单一容器该如何更好的运行,随后不久他们意识到了单一容器本身的管理是没有太大价值的。换句话说,docker自己的价值在单一的docker中并没有发挥出来,而是需要用容器编排系统的支撑他才能发挥出来。因此想法设法的,既要维护容器技术,另外一方面开始去开发容器编排系统。于是就有了docker容器编排三剑客,即docker-machine,docker-swarm以及docker-compose等技术都是docker的容器编排系统。
    
  Apache软件基金会(也就是Apache Software Foundation,简称为ASF)开源的统一资源调度和分配工具Mesos,Mesos结合中间层Marathon就可以实现容器编排功能啦。
  Google这家公司秘而不宣在公司内部使用容器技术(Borg为容器编排技术)已经有十几年的历史啦,据说每一周新建和销毁的容器就多达几十亿个,Docker竟然因缘巧合摸到了这个门道而且还做成了开源软件,此时Google公司就坐不住了,但此时Docker已经在容器技术上独霸话语权啦,而Google内部使用的Borg和Omega均是内部自用的容器调度工具(做大数据运维的小伙伴应该有了解这两个组件)是闭源的,公司内部用的不能直接开源。可惜Docker阵营并不团结,CoreOS公司从Docker分手后,开发了Rocket容器(简称rkt,Github地址为:https://github.com/rkt/rkt)与Docker争雄。此时Google公司扶持Rocket来和Docker反着干。但可惜rkt并不是Docker的对手。此时Google发现Docker容器编排技术依旧是其弱项,于是Google凭借着自己内部使用的Brog和Omage的十几年使用经验开源了kubernetes容器编排技术,Kubernetes(简称K8S)的横空出世这对Docker简直就是降维打击!这让docker自研的容器编排招架不住(这三家公司本来市场打的很精彩的,在2017年12月基本已尘埃落定,K8s占据了80%左右的市场份额,成了实时上的标准。在此基础之上,Google还主导成立了"Cloud Native Computing Foundation",简称"CNCF")。

  有人说Docker技术仍在,Docker公司已死,说是Docker公司拿了一手好牌(Docker容器)却打的稀烂,主要是讽刺Docker公司在容器编排上一无建树。我们作为事后诸葛亮怎么评论都容易,如果让你成为Docker主事者未必能带领Docker走上更好的方向,这也不一定。   
其实kubernetes的在谷歌公司内部得到了很广泛的应用。容器技术很多公司都在搞,Google 再用,阿里也在用,只不过阿里有他们自己的容器化技术,应用的广泛性和Docker还没法比!

3>.Docker发行版本

我们知道Docker在容器编排技术上败给了K8s,大量市场被Google公司拿下,因此它没有找到一个很好的变现方式。
  为了让Docker项目做的更大,目的是吸引更多的投资人,将来未上市就想成为传说中的"独角兽",此时发现Docker这个关键词在互联网上非常火,该公司始终无法变现。于是将Docker开源版做了双发行版本,即Docker社区版和Docke企业版。后来Docker公司负责人讲开源的Docker开源版本更名为"Moby",而互联网想要搜索"Docker"关键词的流量都引入了"Docker 企业版"网站。这样做估计大家也理解,因为它是一家商业公司。后来有一段时间Docker社区版对此做法有很多不满。后来Docker的CEO不得不解释说是为了Docker 社区版更好的发展。很多码农估计都念叨过:“我信你个鬼,你个糟老头子坏得很!”
  K8S将Docker社区版合并的代码贡献给CNCF组织,其目的是要告诉大家Google公司不会讲K8S私有化,这样大家方能大胆使用。现在K8S使用Go语言研发(Docker也是使用Go语言研发),而k8s目前还未成熟,更新版本迭代是相当之快。
  
  最早的时候docker就是一个开源项目,主要由docker公司维护。2017年年初,docker公司将原先的docker项目改名为moby,并创建了docker-ce和docker-ee。这三者的关系是:
    1>.moby是继承了原先的docker的项目,是社区维护的的开源项目,谁都可以在moby的基础打造自己的容器产品;
    2>.docker-ce是docker公司维护的开源项目,是一个基于moby项目的免费的容器产品;
    3>.docker-ee是docker公司维护的闭源产品,是docker公司的商业产品;
moby project由社区维护,docker
-ce project是docker公司维护,docker-ee是闭源的。要使用免费的docker,从网页docker-ce上获取。要使用收费的docker,从网页docker-ee上获取。  
docker
-ce的发布计划v1.13.1之后,发布计划更改为:     Edge: 月版本,每月发布一次,命名格式为YY.MM,维护到下个月的版本发布     Stable: 季度版本,每季度发布一次,命名格式为YY.MM,维护4个月   
  博主推荐阅读一:https:
//blog.csdn.net/m2l0zgssvc7r69efdtj/article/details/78944851   博主推荐阅读二:https://blog.csdn.net/yk20091201/article/details/80016135

4>.Docker种的容器

Docker容器技术基础入门篇第5张

我们现在很多人应该都知道容器目前分为两大组织,一个是Google为首的CNCF组织,该组织有一种另起灶炉想要把Google公司排挤在外的意图,随着容器的发展无疑是要有一款标准化开源产品,而这个标准由谁来定制呢?CNCF完全有这个实例来开发一套容器开源产品,因为该组织里面有意见超大型互联网公司Google,而目前关于容器的发言权依旧是给了Docker公司,由该公司来定制Docker的标准,Docker已经开发libcontainer容器引擎来替换LXC引擎,后来有研发了runC容器引擎来替换libcontainer。现在runC已经称为了容器运行时的工业标准。总的来说,Docker中的容器演变过程为:lxc ---> libcontainer ---> runC 。

后来在Docker的主导下,孕育了OCF和OCI(Open Container Initiative)。
Open Container Initiative(简称OCI):
1>.由Linux仅仅会主导2015年6月创立;
2>.旨在围绕容器格式和运行时定制一个开放的工业化标准;
3>.两个标准分别为运行时标准(the Runtime Specification(runtime-spec))和镜像格式标准(the Image Specification(image-spec));
Open Container Format(简称OCF):
1>.runC是OCF重要实现之一;
2>.目前runC是当前Docker使用的容器引擎;
不管我们怎么认为Docker被人欺负,但是到今天为止,Docker确实是大家心中的容器技术。谈到容器你可能不知道LXC是什么,也可能不知道Linux名称空间到底是什么,但是大家都知道Docker。所以到今天位置无论k8s自己认为在容器编排领域多么一家独大,但依然无法摆脱Docker。尽管K8s支持很多种容器(Docker只是其中一种),但Docker依旧是在主流。在实际工作种大多数都是K8S
+Docker。因此我们想要很好的掌握k8s还不得不要好好学习一下Docker。

四.Docker架构

Docker 采用的是 Client/Server 架构。客户端向服务器发送请求,服务器负责构建、运行和分发容器。客户端和服务器可以运行在同一个 Host 上,客户端也可以通过 socket 或 REST API 与远程的服务器通信。参考链接:https://www.cnblogs.com/CloudMan6/p/6763789.html

Docker容器技术基础入门篇第6张

一.Client:
  Docker 客户端,最常用的 Docker 客户端是 docker 命令。通过docker我们可以方便地在Host上构建和运行容器。
  docker 支持很多操作( docker 命令行工具),用户也可以通过 REST API 与服务器通信。
  Client和Docker daemon通信可使用https/http协议进行通信,为了安全起见,默认使用的就是https协议。
二.Docker daemon:  
    Docker daemon 是服务器组件(Docker 守护进程服务器 ),以 Linux 后台服务的方式运行。
    Docker daemon 运行在 Docker host 上,负责创建、运行、监控容器,构建、存储镜像。默认配置下,Docker daemon 只能响应来自本地 Host 的客户端请求。如果要允许远程客户端请求,需要在配置文件中打开TCP监听(支持IPV4和IPV6)。
三.Image:   
    可将Docker镜像看成只读模板,通过它可以创建Docker容器。例如某个镜像可能包含一个Ubuntu操作系统、一个Apache HTTP Server以及用户开发的Web应用。
    镜像有多种生成方法:
        可以从无到有开始创建镜像;
        也可以下载并使用别人创建好的现成的镜像
        还可以在现有镜像上创建新的镜像
        我们可以将镜像的内容和创建步骤描述在一个文本文件中,这个文件被称作 Dockerfile,通过执行 docker build <docker-file>命令可以构建出 Docker 镜像。
  Docker官方镜像地址:
      https://hub.docker.com/。
阿里的docker镜像地址:
       https://mirrors.aliyun.com/docker-ce/linux/
清华大学docker镜像地址:
      https://mirrors.tuna.tsinghua.edu.cn/docker-ce/

四.Registry:   
我们去构建镜像时,镜像做好之后应该有一个统一存放位置,我们称之为Docker仓库,Registry是存放Docker镜像的仓库(官方默认仓库在
"https://hub.docker.com"),Registry分私有和公有两种。Images和Registry之间默认使用的时https协议,当然如果你非要指定为http协议也是可以的。   启动容器时,docker daemon会试图从本地获取相关的镜像;本地镜像不存在时,其将从Registry中下载该镜像并保存到本地。
Registry用于保存docker镜像,包括镜像的层次结构和元数据。用户可自建Registry,也可使用官方的Docker Hub。
Docker Registry可分为以下几类:
Sponsor Registry:第三方的registry,供客户端和Docker社区使用。
Mirror Registry:第三方的registry,只让客户使用。
Vendor Registry:由发布Docker镜像的供应商提供的registry。
Private Registry:通过设有防火墙和额外的安全层的私有实体提供的registry。
Registry包括Repository和Index,详细说明如下:
Repository:
由某特定的docker镜像的所有迭代版本组成的镜像仓库;
一个Registry中可以存在多个Repository:
Repository可分为"顶层仓库"和"用户仓库";
用户仓库名称格式为"用户名/仓库名"。
每个仓库可以包含多个Tag(标签),每个标签对应一个镜像;
Index:
维护用户账户,镜像的校验以及公共命名空间的信息;
相当于为Registry提供了一个完成用户认证等功能的检索接口。
Docker Registry中的镜像通常由开发人员制作,而后推送至"公共"或"私有"Registry上保存,供其它人员使用,例如"部署"到生产环境。
五.Container:    Docker容器,用于加载Docker镜像。换句话说,Docker容器就是Docker镜像的运行实例。我们知道镜像(Image)是只读的,在启动一个Container时,其实就是基于Image来新建一个专用的可写仓供用户使用。

五.安装Docker

1>.查看Docker-ce的官方文档(https://docs.docker.com/install/

Docker容器技术基础入门篇第7张

2>.下载docker的yum的阿里云源

Docker容器技术基础入门篇第8张Docker容器技术基础入门篇第9张
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# cat /etc/redhat-release 
CentOS Linux release 7.2.1511(Core) 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# yum -y install wget
Loaded plugins: fastestmirror
base                                                                                                                                                                                               | 3.6 kB  00:00:00
extras                                                                                                                                                                                             | 3.4 kB  00:00:00
updates                                                                                                                                                                                            | 3.4 kB  00:00:00
(1/4): base/7/x86_64/group_gz                                                                                                                                                                      | 166 kB  00:00:00
(2/4): extras/7/x86_64/primary_db                                                                                                                                                                  | 187 kB  00:00:00
(3/4): updates/7/x86_64/primary_db                                                                                                                                                                 | 3.3 MB  00:00:02
(4/4): base/7/x86_64/primary_db                                                                                                                                                                    | 6.0 MB  00:00:05
Determining fastest mirrors
 *base: mirrors.aliyun.com
 *extras: mirrors.neusoft.edu.cn
 *updates: mirrors.aliyun.com
Resolving Dependencies
-->Running transaction check
---> Package wget.x86_64 0:1.14-18.el7 will be installed
-->Finished Dependency Resolution
Dependencies Resolved
==========================================================================================================================================================================================================================
 Package                                           Arch                                                Version                                                    Repository                                         Size
==========================================================================================================================================================================================================================
Installing:
 wget                                              x86_64                                              1.14-18.el7                                                base                                              547k
Transaction Summary
==========================================================================================================================================================================================================================
Install  1Package
Total download size: 547k
Installed size: 2.0M
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/wget-1.14-18.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY================================================-     ]  0.0 B/s | 511 kB  --:--:--ETA 
Public key for wget-1.14-18.el7.x86_64.rpm is not installed
wget-1.14-18.el7.x86_64.rpm                                                                                                                                                                        | 547 kB  00:00:00
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-2.1511.el7.centos.2.10.x86_64 (@anaconda)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : wget-1.14-18.el7.x86_64                                                                                                                                                                                1/1
  Verifying  : wget-1.14-18.el7.x86_64                                                                                                                                                                                1/1
Installed:
  wget.x86_64 0:1.14-18.el7                                                                                                                                                                                               
Complete!
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# yum -y install wget
Docker容器技术基础入门篇第8张Docker容器技术基础入门篇第11张
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo  -O /etc/yum.repos.d/docker-ce.repo
--2019-03-23 07:45:05--  https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 116.136.134.81, 27.221.93.97, 27.221.93.93, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|116.136.134.81|:443... connected.
HTTP request sent, awaiting response... 200OK
Length: 2640 (2.6K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/docker-ce.repo’
100%[================================================================================================================================================================================>] 2,640       --.-K/s   in0s      
2019-03-23 07:45:07 (41.1 MB/s) - ‘/etc/yum.repos.d/docker-ce.repo’ saved [2640/2640]
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo

3>.安装docker

Docker容器技术基础入门篇第8张Docker容器技术基础入门篇第13张
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# yum -y install docker-ce
Loaded plugins: fastestmirror
docker-ce-stable                                                                                                                                                                                   | 3.5 kB  00:00:00
(1/2): docker-ce-stable/x86_64/updateinfo                                                                                                                                                          |   55 B  00:00:00
(2/2): docker-ce-stable/x86_64/primary_db                                                                                                                                                          |  25 kB  00:00:00
Loading mirror speeds from cached hostfile
 *base: mirrors.aliyun.com
 *extras: mirrors.neusoft.edu.cn
 *updates: mirrors.aliyun.com
Resolving Dependencies
-->Running transaction check
---> Package docker-ce.x86_64 3:18.09.3-3.el7 will be installed
--> Processing Dependency: container-selinux >= 2.9 for package: 3:docker-ce-18.09.3-3.el7.x86_64
--> Processing Dependency: containerd.io >= 1.2.2-3 for package: 3:docker-ce-18.09.3-3.el7.x86_64
--> Processing Dependency: libseccomp >= 2.3 for package: 3:docker-ce-18.09.3-3.el7.x86_64
--> Processing Dependency: docker-ce-cli for package: 3:docker-ce-18.09.3-3.el7.x86_64
--> Processing Dependency: libcgroup for package: 3:docker-ce-18.09.3-3.el7.x86_64
--> Processing Dependency: libseccomp.so.2()(64bit) for package: 3:docker-ce-18.09.3-3.el7.x86_64
-->Running transaction check
---> Package container-selinux.noarch 2:2.74-1.el7 will be installed
--> Processing Dependency: selinux-policy-targeted >= 3.13.1-216.el7 for package: 2:container-selinux-2.74-1.el7.noarch
--> Processing Dependency: selinux-policy-base >= 3.13.1-216.el7 for package: 2:container-selinux-2.74-1.el7.noarch
--> Processing Dependency: selinux-policy >= 3.13.1-216.el7 for package: 2:container-selinux-2.74-1.el7.noarch
--> Processing Dependency: policycoreutils >= 2.5-11 for package: 2:container-selinux-2.74-1.el7.noarch
--> Processing Dependency: policycoreutils-python for package: 2:container-selinux-2.74-1.el7.noarch
---> Package containerd.io.x86_64 0:1.2.4-3.1.el7 will be installed
---> Package docker-ce-cli.x86_64 1:18.09.3-3.el7 will be installed
---> Package libcgroup.x86_64 0:0.41-20.el7 will be installed
---> Package libseccomp.x86_64 0:2.3.1-3.el7 will be installed
-->Running transaction check
---> Package policycoreutils.x86_64 0:2.2.5-20.el7 will be updated
---> Package policycoreutils.x86_64 0:2.5-29.el7_6.1will be an update
--> Processing Dependency: libsepol >= 2.5-10 for package: policycoreutils-2.5-29.el7_6.1.x86_64
--> Processing Dependency: libsemanage >= 2.5-14 for package: policycoreutils-2.5-29.el7_6.1.x86_64
--> Processing Dependency: libselinux-utils >= 2.5-14 for package: policycoreutils-2.5-29.el7_6.1.x86_64
--> Processing Dependency: libsepol.so.1(LIBSEPOL_1.1)(64bit) for package: policycoreutils-2.5-29.el7_6.1.x86_64
--> Processing Dependency: libsepol.so.1(LIBSEPOL_1.0)(64bit) for package: policycoreutils-2.5-29.el7_6.1.x86_64
--> Processing Dependency: libsemanage.so.1(LIBSEMANAGE_1.1)(64bit) for package: policycoreutils-2.5-29.el7_6.1.x86_64
---> Package policycoreutils-python.x86_64 0:2.5-29.el7_6.1will be installed
--> Processing Dependency: setools-libs >= 3.3.8-4 for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--> Processing Dependency: libsemanage-python >= 2.5-14 for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-29.el7_6.1.x86_64
---> Package selinux-policy.noarch 0:3.13.1-60.el7 will be updated
---> Package selinux-policy.noarch 0:3.13.1-229.el7_6.9will be an update
---> Package selinux-policy-targeted.noarch 0:3.13.1-60.el7 will be updated
---> Package selinux-policy-targeted.noarch 0:3.13.1-229.el7_6.9will be an update
-->Running transaction check
---> Package audit-libs-python.x86_64 0:2.8.4-4.el7 will be installed
--> Processing Dependency: audit-libs(x86-64) = 2.8.4-4.el7 for package: audit-libs-python-2.8.4-4.el7.x86_64
---> Package checkpolicy.x86_64 0:2.5-8.el7 will be installed
---> Package libselinux-utils.x86_64 0:2.2.2-6.el7 will be updated
---> Package libselinux-utils.x86_64 0:2.5-14.1.el7 will be an update
--> Processing Dependency: libselinux(x86-64) = 2.5-14.1.el7 for package: libselinux-utils-2.5-14.1.el7.x86_64
---> Package libsemanage.x86_64 0:2.1.10-18.el7 will be updated
---> Package libsemanage.x86_64 0:2.5-14.el7 will be an update
---> Package libsemanage-python.x86_64 0:2.5-14.el7 will be installed
---> Package libsepol.x86_64 0:2.1.9-3.el7 will be updated
---> Package libsepol.x86_64 0:2.5-10.el7 will be an update
---> Package python-IPy.noarch 0:0.75-6.el7 will be installed
---> Package setools-libs.x86_64 0:3.3.8-4.el7 will be installed
-->Running transaction check
---> Package audit-libs.x86_64 0:2.4.1-5.el7 will be updated
--> Processing Dependency: audit-libs = 2.4.1-5.el7 for package: audit-2.4.1-5.el7.x86_64
---> Package audit-libs.x86_64 0:2.8.4-4.el7 will be an update
---> Package libselinux.x86_64 0:2.2.2-6.el7 will be updated
--> Processing Dependency: libselinux = 2.2.2-6.el7 for package: libselinux-python-2.2.2-6.el7.x86_64
---> Package libselinux.x86_64 0:2.5-14.1.el7 will be an update
-->Running transaction check
---> Package audit.x86_64 0:2.4.1-5.el7 will be updated
---> Package audit.x86_64 0:2.8.4-4.el7 will be an update
---> Package libselinux-python.x86_64 0:2.2.2-6.el7 will be updated
---> Package libselinux-python.x86_64 0:2.5-14.1.el7 will be an update
--> Processing Conflict: libselinux-2.5-14.1.el7.x86_64 conflicts systemd < 219-20
-->Restarting Dependency Resolution with new changes.
-->Running transaction check
---> Package systemd.x86_64 0:219-19.el7 will be updated
--> Processing Dependency: systemd = 219-19.el7 for package: systemd-sysv-219-19.el7.x86_64
---> Package systemd.x86_64 0:219-62.el7_6.5will be an update
--> Processing Dependency: systemd-libs = 219-62.el7_6.5 for package: systemd-219-62.el7_6.5.x86_64
--> Processing Dependency: libcryptsetup.so.12(CRYPTSETUP_2.0)(64bit) for package: systemd-219-62.el7_6.5.x86_64
--> Processing Dependency: liblz4.so.1()(64bit) for package: systemd-219-62.el7_6.5.x86_64
--> Processing Dependency: libcryptsetup.so.12()(64bit) for package: systemd-219-62.el7_6.5.x86_64
-->Running transaction check
---> Package cryptsetup-libs.x86_64 0:1.6.7-1.el7 will be updated
---> Package cryptsetup-libs.x86_64 0:2.0.3-3.el7 will be an update
---> Package lz4.x86_64 0:1.7.5-2.el7 will be installed
---> Package systemd-libs.x86_64 0:219-19.el7 will be updated
--> Processing Dependency: systemd-libs = 219-19.el7 for package: libgudev1-219-19.el7.x86_64
---> Package systemd-libs.x86_64 0:219-62.el7_6.5will be an update
---> Package systemd-sysv.x86_64 0:219-19.el7 will be updated
---> Package systemd-sysv.x86_64 0:219-62.el7_6.5will be an update
-->Running transaction check
---> Package libgudev1.x86_64 0:219-19.el7 will be updated
---> Package libgudev1.x86_64 0:219-62.el7_6.5will be an update
-->Finished Dependency Resolution
Dependencies Resolved
==========================================================================================================================================================================================================================
 Package                                                     Arch                                       Version                                                Repository                                            Size
==========================================================================================================================================================================================================================
Installing:
 docker-ce                                                   x86_64                                     3:18.09.3-3.el7                                        docker-ce-stable                                      19M
Updating:
 systemd                                                     x86_64                                     219-62.el7_6.5                                         updates                                              5.1M
Installing fordependencies:
 audit-libs-python                                           x86_64                                     2.8.4-4.el7                                            base                                                  76k
 checkpolicy                                                 x86_64                                     2.5-8.el7                                              base                                                 295k
 container-selinux                                           noarch                                     2:2.74-1.el7                                           extras                                                38k
 containerd.io                                               x86_64                                     1.2.4-3.1.el7                                          docker-ce-stable                                      22M
 docker-ce-cli                                               x86_64                                     1:18.09.3-3.el7                                        docker-ce-stable                                      14M
 libcgroup                                                   x86_64                                     0.41-20.el7                                            base                                                  66k
 libseccomp                                                  x86_64                                     2.3.1-3.el7                                            base                                                  56k
 libsemanage-python                                          x86_64                                     2.5-14.el7                                             base                                                 113k
 lz4                                                         x86_64                                     1.7.5-2.el7                                            base                                                  98k
 policycoreutils-python                                      x86_64                                     2.5-29.el7_6.1                                         updates                                              456k
 python-IPy                                                  noarch                                     0.75-6.el7                                             base                                                  32k
 setools-libs                                                x86_64                                     3.3.8-4.el7                                            base                                                 620k
Updating fordependencies:
 audit                                                       x86_64                                     2.8.4-4.el7                                            base                                                 250k
 audit-libs                                                  x86_64                                     2.8.4-4.el7                                            base                                                 100k
 cryptsetup-libs                                             x86_64                                     2.0.3-3.el7                                            base                                                 338k
 libgudev1                                                   x86_64                                     219-62.el7_6.5                                         updates                                               96k
 libselinux                                                  x86_64                                     2.5-14.1.el7                                           base                                                 162k
 libselinux-python                                           x86_64                                     2.5-14.1.el7                                           base                                                 235k
 libselinux-utils                                            x86_64                                     2.5-14.1.el7                                           base                                                 151k
 libsemanage                                                 x86_64                                     2.5-14.el7                                             base                                                 151k
 libsepol                                                    x86_64                                     2.5-10.el7                                             base                                                 297k
 policycoreutils                                             x86_64                                     2.5-29.el7_6.1                                         updates                                              916k
 selinux-policy                                              noarch                                     3.13.1-229.el7_6.9                                     updates                                              483k
 selinux-policy-targeted                                     noarch                                     3.13.1-229.el7_6.9                                     updates                                              6.9M
 systemd-libs                                                x86_64                                     219-62.el7_6.5                                         updates                                              407k
 systemd-sysv                                                x86_64                                     219-62.el7_6.5                                         updates                                               84k
Transaction Summary
==========================================================================================================================================================================================================================
Install  1 Package (+12Dependent packages)
Upgrade  1 Package (+14Dependent packages)
Total download size: 72M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/28): audit-libs-python-2.8.4-4.el7.x86_64.rpm                                                                                                                                                   |  76 kB  00:00:00
(2/28): audit-libs-2.8.4-4.el7.x86_64.rpm                                                                                                                                                          | 100 kB  00:00:00
(3/28): container-selinux-2.74-1.el7.noarch.rpm                                                                                                                                                    |  38 kB  00:00:00
(4/28): audit-2.8.4-4.el7.x86_64.rpm                                                                                                                                                               | 250 kB  00:00:00
(5/28): checkpolicy-2.5-8.el7.x86_64.rpm                                                                                                                                                           | 295 kB  00:00:00
(6/28): cryptsetup-libs-2.0.3-3.el7.x86_64.rpm                                                                                                                                                     | 338 kB  00:00:00
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-18.09.3-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEY                                   ] 4.4 MB/s |  38 MB  00:00:07ETA 
Public key for docker-ce-18.09.3-3.el7.x86_64.rpm is not installed
(7/28): docker-ce-18.09.3-3.el7.x86_64.rpm                                                                                                                                                         |  19 MB  00:00:07
(8/28): libseccomp-2.3.1-3.el7.x86_64.rpm                                                                                                                                                          |  56 kB  00:00:00
(9/28): libselinux-2.5-14.1.el7.x86_64.rpm                                                                                                                                                         | 162 kB  00:00:00
(10/28): libcgroup-0.41-20.el7.x86_64.rpm                                                                                                                                                          |  66 kB  00:00:00
(11/28): libgudev1-219-62.el7_6.5.x86_64.rpm                                                                                                                                                       |  96 kB  00:00:00
(12/28): libselinux-utils-2.5-14.1.el7.x86_64.rpm                                                                                                                                                  | 151 kB  00:00:00
(13/28): libselinux-python-2.5-14.1.el7.x86_64.rpm                                                                                                                                                 | 235 kB  00:00:00
(14/28): libsemanage-python-2.5-14.el7.x86_64.rpm                                                                                                                                                  | 113 kB  00:00:00
(15/28): libsemanage-2.5-14.el7.x86_64.rpm                                                                                                                                                         | 151 kB  00:00:00
(16/28): libsepol-2.5-10.el7.x86_64.rpm                                                                                                                                                            | 297 kB  00:00:00
(17/28): lz4-1.7.5-2.el7.x86_64.rpm                                                                                                                                                                |  98 kB  00:00:00
(18/28): python-IPy-0.75-6.el7.noarch.rpm                                                                                                                                                          |  32 kB  00:00:00
(19/28): containerd.io-1.2.4-3.1.el7.x86_64.rpm                                                                                                                                                    |  22 MB  00:00:08
(20/28): policycoreutils-2.5-29.el7_6.1.x86_64.rpm                                                                                                                                                 | 916 kB  00:00:00
(21/28): selinux-policy-3.13.1-229.el7_6.9.noarch.rpm                                                                                                                                              | 483 kB  00:00:00
(22/28): policycoreutils-python-2.5-29.el7_6.1.x86_64.rpm                                                                                                                                          | 456 kB  00:00:00
setools-libs-3.3.8-4.el7.x86_6 FAILED                                          
http://mirrors.aliyun.com/centos/7.6.1810/os/x86_64/Packages/setools-libs-3.3.8-4.el7.x86_64.rpm: [Errno 14] curl#18 - "transfer closed with 110896 bytes remaining to read"            ] 4.9 MB/s |  47 MB  00:00:05 ETA 
Trying other mirror.
(23/28): systemd-libs-219-62.el7_6.5.x86_64.rpm                                                                                                                                                    | 407 kB  00:00:00
(24/28): setools-libs-3.3.8-4.el7.x86_64.rpm                                                                                                                                                       | 620 kB  00:00:00
(25/28): systemd-219-62.el7_6.5.x86_64.rpm                                                                                                                                                         | 5.1 MB  00:00:02
(26/28): systemd-sysv-219-62.el7_6.5.x86_64.rpm                                                                                                                                                    |  84 kB  00:00:02
(27/28): docker-ce-cli-18.09.3-3.el7.x86_64.rpm                                                                                                                                                    |  14 MB  00:00:05
(28/28): selinux-policy-targeted-3.13.1-229.el7_6.9.noarch.rpm                                                                                                                                     | 6.9 MB  00:00:06     
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                     4.6 MB/s |  72 MB  00:00:15
Retrieving key from https://mirrors.aliyun.com/docker-ce/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://mirrors.aliyun.com/docker-ce/linux/centos/gpg
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : libsepol-2.5-10.el7.x86_64                                                                                                                                                                            1/43
  Updating   : libselinux-2.5-14.1.el7.x86_64                                                                                                                                                                        2/43
  Updating   : audit-libs-2.8.4-4.el7.x86_64                                                                                                                                                                         3/43
  Updating   : libsemanage-2.5-14.el7.x86_64                                                                                                                                                                         4/43
  Updating   : libselinux-utils-2.5-14.1.el7.x86_64                                                                                                                                                                  5/43
  Updating   : policycoreutils-2.5-29.el7_6.1.x86_64                                                                                                                                                                 6/43
  Updating   : selinux-policy-3.13.1-229.el7_6.9.noarch                                                                                                                                                              7/43
  Installing : lz4-1.7.5-2.el7.x86_64                                                                                                                                                                                8/43
  Updating   : systemd-libs-219-62.el7_6.5.x86_64                                                                                                                                                                    9/43
  Updating   : selinux-policy-targeted-3.13.1-229.el7_6.9.noarch                                                                                                                                                    10/43
  Installing : libsemanage-python-2.5-14.el7.x86_64                                                                                                                                                                 11/43
  Installing : audit-libs-python-2.8.4-4.el7.x86_64                                                                                                                                                                 12/43
  Installing : setools-libs-3.3.8-4.el7.x86_64                                                                                                                                                                      13/43
  Updating   : libselinux-python-2.5-14.1.el7.x86_64                                                                                                                                                                14/43
  Installing : 1:docker-ce-cli-18.09.3-3.el7.x86_64                                                                                                                                                                 15/43
  Installing : checkpolicy-2.5-8.el7.x86_64                                                                                                                                                                         16/43
  Installing : python-IPy-0.75-6.el7.noarch                                                                                                                                                                         17/43
  Updating   : cryptsetup-libs-2.0.3-3.el7.x86_64                                                                                                                                                                   18/43
  Updating   : systemd-219-62.el7_6.5.x86_64                                                                                                                                                                        19/43
  Installing : libcgroup-0.41-20.el7.x86_64                                                                                                                                                                         20/43
  Installing : policycoreutils-python-2.5-29.el7_6.1.x86_64                                                                                                                                                         21/43
  Installing : 2:container-selinux-2.74-1.el7.noarch                                                                                                                                                                22/43
  Updating   : systemd-sysv-219-62.el7_6.5.x86_64                                                                                                                                                                   23/43
  Installing : containerd.io-1.2.4-3.1.el7.x86_64                                                                                                                                                                   24/43
  Installing : libseccomp-2.3.1-3.el7.x86_64                                                                                                                                                                        25/43
  Installing : 3:docker-ce-18.09.3-3.el7.x86_64                                                                                                                                                                     26/43
  Updating   : audit-2.8.4-4.el7.x86_64                                                                                                                                                                             27/43
  Updating   : libgudev1-219-62.el7_6.5.x86_64                                                                                                                                                                      28/43
  Cleanup    : audit-2.4.1-5.el7.x86_64                                                                                                                                                                             29/43
  Cleanup    : selinux-policy-targeted-3.13.1-60.el7.noarch                                                                                                                                                         30/43
  Cleanup    : selinux-policy-3.13.1-60.el7.noarch                                                                                                                                                                  31/43
  Cleanup    : systemd-sysv-219-19.el7.x86_64                                                                                                                                                                       32/43
  Cleanup    : policycoreutils-2.2.5-20.el7.x86_64                                                                                                                                                                  33/43
  Cleanup    : systemd-219-19.el7.x86_64                                                                                                                                                                            34/43
  Cleanup    : libsemanage-2.1.10-18.el7.x86_64                                                                                                                                                                     35/43
  Cleanup    : libselinux-utils-2.2.2-6.el7.x86_64                                                                                                                                                                  36/43
  Cleanup    : libselinux-python-2.2.2-6.el7.x86_64                                                                                                                                                                 37/43
  Cleanup    : libgudev1-219-19.el7.x86_64                                                                                                                                                                          38/43
  Cleanup    : systemd-libs-219-19.el7.x86_64                                                                                                                                                                       39/43
  Cleanup    : libselinux-2.2.2-6.el7.x86_64                                                                                                                                                                        40/43
  Cleanup    : libsepol-2.1.9-3.el7.x86_64                                                                                                                                                                          41/43
  Cleanup    : audit-libs-2.4.1-5.el7.x86_64                                                                                                                                                                        42/43
  Cleanup    : cryptsetup-libs-1.6.7-1.el7.x86_64                                                                                                                                                                   43/43
  Verifying  : libcgroup-0.41-20.el7.x86_64                                                                                                                                                                          1/43
  Verifying  : libseccomp-2.3.1-3.el7.x86_64                                                                                                                                                                         2/43
  Verifying  : 2:container-selinux-2.74-1.el7.noarch                                                                                                                                                                 3/43
  Verifying  : policycoreutils-2.5-29.el7_6.1.x86_64                                                                                                                                                                 4/43
  Verifying  : cryptsetup-libs-2.0.3-3.el7.x86_64                                                                                                                                                                    5/43
  Verifying  : audit-libs-2.8.4-4.el7.x86_64                                                                                                                                                                         6/43
  Verifying  : audit-2.8.4-4.el7.x86_64                                                                                                                                                                              7/43
  Verifying  : python-IPy-0.75-6.el7.noarch                                                                                                                                                                          8/43
  Verifying  : setools-libs-3.3.8-4.el7.x86_64                                                                                                                                                                       9/43
  Verifying  : systemd-219-62.el7_6.5.x86_64                                                                                                                                                                        10/43
  Verifying  : policycoreutils-python-2.5-29.el7_6.1.x86_64                                                                                                                                                         11/43
  Verifying  : libgudev1-219-62.el7_6.5.x86_64                                                                                                                                                                      12/43
  Verifying  : systemd-libs-219-62.el7_6.5.x86_64                                                                                                                                                                   13/43
  Verifying  : libsemanage-python-2.5-14.el7.x86_64                                                                                                                                                                 14/43
  Verifying  : selinux-policy-3.13.1-229.el7_6.9.noarch                                                                                                                                                             15/43
  Verifying  : libsemanage-2.5-14.el7.x86_64                                                                                                                                                                        16/43
  Verifying  : selinux-policy-targeted-3.13.1-229.el7_6.9.noarch                                                                                                                                                    17/43
  Verifying  : lz4-1.7.5-2.el7.x86_64                                                                                                                                                                               18/43
  Verifying  : libsepol-2.5-10.el7.x86_64                                                                                                                                                                           19/43
  Verifying  : checkpolicy-2.5-8.el7.x86_64                                                                                                                                                                         20/43
  Verifying  : systemd-sysv-219-62.el7_6.5.x86_64                                                                                                                                                                   21/43
  Verifying  : libselinux-python-2.5-14.1.el7.x86_64                                                                                                                                                                22/43
  Verifying  : audit-libs-python-2.8.4-4.el7.x86_64                                                                                                                                                                 23/43
  Verifying  : libselinux-utils-2.5-14.1.el7.x86_64                                                                                                                                                                 24/43
  Verifying  : 1:docker-ce-cli-18.09.3-3.el7.x86_64                                                                                                                                                                 25/43
  Verifying  : libselinux-2.5-14.1.el7.x86_64                                                                                                                                                                       26/43
  Verifying  : 3:docker-ce-18.09.3-3.el7.x86_64                                                                                                                                                                     27/43
  Verifying  : containerd.io-1.2.4-3.1.el7.x86_64                                                                                                                                                                   28/43
  Verifying  : systemd-sysv-219-19.el7.x86_64                                                                                                                                                                       29/43
  Verifying  : selinux-policy-targeted-3.13.1-60.el7.noarch                                                                                                                                                         30/43
  Verifying  : libsemanage-2.1.10-18.el7.x86_64                                                                                                                                                                     31/43
  Verifying  : libgudev1-219-19.el7.x86_64                                                                                                                                                                          32/43
  Verifying  : systemd-219-19.el7.x86_64                                                                                                                                                                            33/43
  Verifying  : selinux-policy-3.13.1-60.el7.noarch                                                                                                                                                                  34/43
  Verifying  : systemd-libs-219-19.el7.x86_64                                                                                                                                                                       35/43
  Verifying  : libselinux-utils-2.2.2-6.el7.x86_64                                                                                                                                                                  36/43
  Verifying  : cryptsetup-libs-1.6.7-1.el7.x86_64                                                                                                                                                                   37/43
  Verifying  : libsepol-2.1.9-3.el7.x86_64                                                                                                                                                                          38/43
  Verifying  : libselinux-python-2.2.2-6.el7.x86_64                                                                                                                                                                 39/43
  Verifying  : audit-libs-2.4.1-5.el7.x86_64                                                                                                                                                                        40/43
  Verifying  : policycoreutils-2.2.5-20.el7.x86_64                                                                                                                                                                  41/43
  Verifying  : audit-2.4.1-5.el7.x86_64                                                                                                                                                                             42/43
  Verifying  : libselinux-2.2.2-6.el7.x86_64                                                                                                                                                                        43/43
Installed:
  docker-ce.x86_64 3:18.09.3-3.el7                                                                                                                                                                                        
Dependency Installed:
  audit-libs-python.x86_64 0:2.8.4-4.el7     checkpolicy.x86_64 0:2.5-8.el7        container-selinux.noarch 2:2.74-1.el7      containerd.io.x86_64 0:1.2.4-3.1.el7     docker-ce-cli.x86_64 1:18.09.3-3.el7              
  libcgroup.x86_64 0:0.41-20.el7             libseccomp.x86_64 0:2.3.1-3.el7       libsemanage-python.x86_64 0:2.5-14.el7     lz4.x86_64 0:1.7.5-2.el7                 policycoreutils-python.x86_64 0:2.5-29.el7_6.1
  python-IPy.noarch 0:0.75-6.el7             setools-libs.x86_64 0:3.3.8-4.el7    
Updated:
  systemd.x86_64 0:219-62.el7_6.5
Dependency Updated:
  audit.x86_64 0:2.8.4-4.el7                  audit-libs.x86_64 0:2.8.4-4.el7                      cryptsetup-libs.x86_64 0:2.0.3-3.el7  libgudev1.x86_64 0:219-62.el7_6.5     libselinux.x86_64 0:2.5-14.1.el7        
  libselinux-python.x86_64 0:2.5-14.1.el7     libselinux-utils.x86_64 0:2.5-14.1.el7               libsemanage.x86_64 0:2.5-14.el7       libsepol.x86_64 0:2.5-10.el7          policycoreutils.x86_64 0:2.5-29.el7_6.1
  selinux-policy.noarch 0:3.13.1-229.el7_6.9  selinux-policy-targeted.noarch 0:3.13.1-229.el7_6.9  systemd-libs.x86_64 0:219-62.el7_6.5  systemd-sysv.x86_64 0:219-62.el7_6.5
Complete!
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# yum -y install docker-ce

4>.使用案例的镜像加速器(需要登录阿里云账号)

Docker容器技术基础入门篇第14张

5>.Docker 中国官方镜像加速(不需要登录)

除了使用阿里云账号的加速器,咱们还可以使用 其他的加速方式https://www.docker-cn.com/registry-mirror

Docker容器技术基础入门篇第15张

6>.启动docker

[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# mkdir /etc/docker
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# vi /etc/docker/daemon.json
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# cat /etc/docker/daemon.json
{
  "registry-mirrors": ["https://tuv7rqqq.mirror.aliyuncs.com"]
}
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# systemctl daemon-reload
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# systemctl start docker
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
Docker容器技术基础入门篇第8张Docker容器技术基础入门篇第17张
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker
Usage:    docker [OPTIONS] COMMAND
A self-sufficient runtime forcontainers
Options:
      --config string      Location of client config files (default "/root/.docker")
  -D, --debug              Enable debug mode
  -H, --host list          Daemon socket(s) to connect to
  -l, --log-level string   Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
      --tls                Use TLS; implied by --tlsverify
      --tlscacert string   Trust certs signed only by this CA (default "/root/.docker/ca.pem")
      --tlscert string     Path to TLS certificate file (default "/root/.docker/cert.pem")
      --tlskey string      Path to TLS key file (default "/root/.docker/key.pem")
      --tlsverify          Use TLS and verify the remote
  -v, --version            Print version information and quit
Management Commands:
  builder     Manage builds
  config      Manage Docker configs
  container   Manage containers
  engine      Manage the docker engine
  image       Manage images
  network     Manage networks
  node        Manage Swarm nodes
  plugin      Manage plugins
  secret      Manage Docker secrets
  service     Manage services
  stack       Manage Docker stacks
  swarm       Manage Swarm
  system      Manage Docker
  trust       Manage trust on Docker images
  volume      Manage volumes
Commands:
  attach      Attach local standard input, output, and error streams to a running container
  build       Build an image from a Dockerfile
  commit      Create a new image from a container's changes
  cp          Copy files/folders between a container and the local filesystem
  create      Create a new container
  diff        Inspect changes to files or directories on a container's filesystem
  events      Get real timeevents from the server
  exec        Run a command ina running container
  export      Export a container's filesystem as a tar archive
history     Show the history of an image
  images      List images
  import      Import the contents from a tarball to create a filesystem image
  info        Display system-wide information
  inspect     Return low-level information on Docker objects
  kill        Kill one or morerunning containers
  load        Load an image from a tararchive or STDIN
  login       Log into a Docker registry
  logout      Log out from a Docker registry
  logs        Fetch the logs of a container
  pause       Pause all processes within one or morecontainers
  port        List port mappings or a specific mapping forthe container
  psList containers
  pull        Pull an image or a repository from a registry
  push        Push an image or a repository to a registry
  rename      Rename a container
  restart     Restart one or morecontainers
  rm          Remove one or morecontainers
  rmi         Remove one or moreimages
  run         Run a command ina new container
  save        Save one or more images to a tararchive (streamed to STDOUT by default)
  search      Search the Docker Hub forimages
  start       Start one or morestopped containers
  stats       Display a live stream of container(s) resource usage statistics
  stop        Stop one or morerunning containers
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
  top         Display the running processes of a container
  unpause     Unpause all processes within one or morecontainers
  update      Update configuration of one or morecontainers
  version     Show the Docker version information
  wait        Block until one or more containers stop, thenprint their exit codes
Run 'docker COMMAND --help' for moreinformation on a command.
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker              #可查看docker的命令使用方式

7>.查看docker信息

Docker容器技术基础入门篇第8张Docker容器技术基础入门篇第19张
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker version
Client:
 Version:           18.09.3
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        774a1f4
 Built:             Thu Feb 28 06:33:21 2019
 OS/Arch:           linux/amd64
 Experimental:      false
Server: Docker Engine -Community
 Engine:
  Version:          18.09.3
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.8
  Git commit:       774a1f4
  Built:            Thu Feb 28 06:02:24 2019
  OS/Arch:          linux/amd64
  Experimental:     false
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker version          #查看docker的版本信息
Docker容器技术基础入门篇第8张Docker容器技术基础入门篇第21张
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 18.09.3
Storage Driver: devicemapper
 Pool Name: docker-8:3-134564763-pool
 Pool Blocksize: 65.54kB
 Base Device Size: 10.74GB
 Backing Filesystem: xfs
 Udev Sync Supported: true
 Data file: /dev/loop0
 Metadata file: /dev/loop1
 Data loop file: /var/lib/docker/devicemapper/devicemapper/data
 Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
 Data Space Used: 11.8MB
 Data Space Total: 107.4GB
 Data Space Available: 49.96GB
 Metadata Space Used: 581.6kB
 Metadata Space Total: 2.147GB
 Metadata Space Available: 2.147GB
 Thin Pool Minimum Free Space: 10.74GB
 Deferred Removal Enabled: true
 Deferred Deletion Enabled: true
 Deferred Deleted Device Count: 0
 Library Version: 1.02.107-RHEL7 (2015-10-14)
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan nulloverlay
 Log: awslogs fluentd gcplogs gelf journald json-filelocal logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: e6b3f5632f50dbc4e9cb6288d911bf4f5e95b18e
runc version: 6635b4f0c6af3810594d2770f662f34ddc15b40d
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 3.10.0-327.el7.x86_64
Operating System: CentOS Linux 7(Core)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 3.688GiB
Name: node101.yinzhengjie.org.cn
ID: BHP7:OYDA:JWKP:ALPE:E7PX:RVJV:HHXC:JIJ6:IOCV:AWMK:LQFI:7IYH
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Registry Mirrors:
 https://tuv7rqqq.mirror.aliyuncs.com/
Live Restore Enabled: false
Product License: Community Engine
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
WARNING: the devicemapper storage-driver is deprecated, and will be removed ina future release.
WARNING: devicemapper: usage of loopback devices is strongly discouraged forproduction use.
         Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker info            #查看docker的详细信息

六.Docker的常用操作

1>.查看命令的帮助信息

Docker容器技术基础入门篇第8张Docker容器技术基础入门篇第23张
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker image --help
Usage:    docker image COMMAND
Manage images
Commands:
  build       Build an image from a Dockerfile
  history     Show the history of an image
  import      Import the contents from a tarball to create a filesystem image
  inspect     Display detailed information on one or moreimages
  load        Load an image from a tararchive or STDIN
  lsList images
  prune       Remove unused images
  pull        Pull an image or a repository from a registry
  push        Push an image or a repository to a registry
  rm          Remove one or moreimages
  save        Save one or more images to a tararchive (streamed to STDOUT by default)
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
Run 'docker image COMMAND --help' for moreinformation on a command.
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker image --help         #查看docker的image命令使用
Docker容器技术基础入门篇第8张Docker容器技术基础入门篇第25张
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker container --help
Usage:    docker container COMMAND
Manage containers
Commands:
  attach      Attach local standard input, output, and error streams to a running container
  commit      Create a new image from a container's changes
  cp          Copy files/folders between a container and the local filesystem
  create      Create a new container
  diff        Inspect changes to files or directories on a container's filesystem
  exec        Run a command ina running container
  export      Export a container's filesystem as a tar archive
  inspect     Display detailed information on one or morecontainers
  kill        Kill one or morerunning containers
  logs        Fetch the logs of a container
  lsList containers
  pause       Pause all processes within one or morecontainers
  port        List port mappings or a specific mapping forthe container
  prune       Remove all stopped containers
  rename      Rename a container
  restart     Restart one or morecontainers
  rm          Remove one or morecontainers
  run         Run a command ina new container
  start       Start one or morestopped containers
  stats       Display a live stream of container(s) resource usage statistics
  stop        Stop one or morerunning containers
  top         Display the running processes of a container
  unpause     Unpause all processes within one or morecontainers
  update      Update configuration of one or morecontainers
  wait        Block until one or more containers stop, thenprint their exit codes
Run 'docker container COMMAND --help' for moreinformation on a command.
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker container --help       #查看container命令的使用

2>.docker event state

Docker容器技术基础入门篇第26张

3>.获取docker镜像-redis(docker官方的镜像下载地址:https://hub.docker.com/

Docker容器技术基础入门篇第8张Docker容器技术基础入门篇第28张
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker search redis
NAME                             DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
redis                            Redis is an open source key-value store that…   6677[OK]                
bitnami/redis                    Bitnami Redis Docker Image                      107[OK]
sameersbn/redis                                                                  76[OK]
grokzen/redis-cluster            Redis cluster 3.0, 3.2, 4.0 & 5.0               44
hypriot/rpi-redis                Raspberry Pi compatible redis image             33
kubeguide/redis-master           redis-master with "Hello World!"                28
rediscommander/redis-commander   Alpine image for redis-commander - Redis man21[OK]
redislabs/redis                  Clustered in-memory database engine compatib…   19
redislabs/redisearch             Redis With the RedisSearch module pre-loaded…   15
arm32v7/redis                    Redis is an open source key-value store that…   14
oliver006/redis_exporter          Prometheus Exporter for Redis Metrics. Supp…   10
webhippie/redis                  Docker images for Redis                         10[OK]
insready/redis-stat              Docker image for the real-time Redis monitor…   7[OK]
s7anley/redis-sentinel-docker    Redis Sentinel                                  7[OK]
rtoma/logspout-redis-logstash    Logspout including Redis adapter for sending…   5
arm64v8/redis                    Redis is an open source key-value store that…   5
centos/redis-32-centos7          Redis in-memory data structure store, used a…   4
redislabs/redisgraph             A graph database module for Redis               4[OK]
wodby/redis                      Redis container image with orchestration        2[OK]
frodenas/redis                   A Docker Image for Redis                        2[OK]
circleci/redis                   CircleCI images for Redis                       2[OK]
tiredofit/redis                  Redis Server w/ Zabbix monitoring and S6 Ove…   1[OK]
cflondonservices/redis           Docker image for running redis                  0
xetamus/redis-resource           forked redis-resource                           0[OK]
iadvize/redis                                                                    0
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker search redis                #查询包含redis字样的镜像
Docker容器技术基础入门篇第8张Docker容器技术基础入门篇第30张
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker pull redis:4-alpine
4-alpine: Pulling from library/redis
8e402f1a9c57: Pull complete 
4c2113a1bbc9: Pull complete 
a4b5ad98d179: Pull complete 
41457a7cc0c5: Pull complete 
f987c6e1a2b3: Pull complete 
2a3ef38f1fd4: Pull complete 
Digest: sha256:7a543f606ea3e055a18ccbda719fb1e04f6922078f733cb39863619983e05031
Status: Downloaded newer image for redis:4-alpine
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker pull redis:4-alpine            #下载一个redis镜像,并指定其tag为4-alpine
Docker容器技术基础入门篇第8张Docker容器技术基础入门篇第32张
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
redis               4-alpine            adbfeec2927e        3 days ago          36.2MB
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker image ls                   #查看已经有的镜像
Docker容器技术基础入门篇第8张Docker容器技术基础入门篇第34张
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
redis               4-alpine            adbfeec2927e        3 days ago          36.2MB
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker image inspect redis:4-alpine
[
    {
        "Id": "sha256:adbfeec2927ea132da957bac11f683ae695bbcbf65afc9d60020f9d1ad95668a",
        "RepoTags": [
            "redis:4-alpine"
        ],
        "RepoDigests": [
            "redis@sha256:7a543f606ea3e055a18ccbda719fb1e04f6922078f733cb39863619983e05031"
        ],
        "Parent": "",
        "Comment": "",
        "Created": "2019-03-19T21:38:25.77087877Z",
        "Container": "b6c63fa16c4cbd45cf0e3c1d96845cf4316b7c43fdcadf22617c7fc60f365e3f",
        "ContainerConfig": {
            "Hostname": "b6c63fa16c4c",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "6379/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "REDIS_VERSION=4.0.14",
                "REDIS_DOWNLOAD_URL=http://download.redis.io/releases/redis-4.0.14.tar.gz",
                "REDIS_DOWNLOAD_SHA=1e1e18420a86cfb285933123b04a82e1ebda20bfb0a289472745a087587e93a7"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "#(nop) ",
                "CMD ["redis-server"]"
            ],
            "ArgsEscaped": true,
            "Image": "sha256:44db1a08fc16d4dfbf4519cbd8d0ca0a33cd3871d0e92ba8c74bf177f356e889",
            "Volumes": {
                "/data": {}
            },
            "WorkingDir": "/data",
            "Entrypoint": [
                "docker-entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": {}
        },
        "DockerVersion": "18.06.1-ce",
        "Author": "",
        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "6379/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
                "REDIS_VERSION=4.0.14",
                "REDIS_DOWNLOAD_URL=http://download.redis.io/releases/redis-4.0.14.tar.gz",
                "REDIS_DOWNLOAD_SHA=1e1e18420a86cfb285933123b04a82e1ebda20bfb0a289472745a087587e93a7"
            ],
            "Cmd": [
                "redis-server"
            ],
            "ArgsEscaped": true,
            "Image": "sha256:44db1a08fc16d4dfbf4519cbd8d0ca0a33cd3871d0e92ba8c74bf177f356e889",
            "Volumes": {
                "/data": {}
            },
            "WorkingDir": "/data",
            "Entrypoint": [
                "docker-entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": null
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 36192469,
        "VirtualSize": 36192469,
        "GraphDriver": {
            "Data": {
                "DeviceId": "7",
                "DeviceName": "docker-8:3-134564763-f6b941f961280569e170c2ba9ebe9ec5d849609596eb865fdf58d14282279955",
                "DeviceSize": "10737418240"
            },
            "Name": "devicemapper"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:bcf2f368fe234217249e00ad9d762d8f1a3156d60c442ed92079fa5b120634a1",
                "sha256:53b9ee4aa890cdf6fb54072145bc91e6e9f75aa37f49eeef7e177503449f4124",
                "sha256:abd36062f9fec1abd0b1a104476b3700763a9fdf6ea8ddc18687dea0609bb864",
                "sha256:f55d74f1440715c06b12175fc1afbfa9e872d3b9cceb4194e3f13640b8aef100",
                "sha256:8e10865a11e52a9812472898d45d46a151c71aef4aa20e361d1ce92790891056",
                "sha256:84b5f025422880a5dbb6536ef9053cfa515e09fb46bd6bf3b92c8e6f29fcdaf2"
            ]
        },
        "Metadata": {
            "LastTagTime": "0001-01-01T00:00:00Z"
        }
    }
]
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker image inspect redis:4-alpine      #查看某个镜像的详细信息

4>.启获取docker镜像-CentOS

Docker容器技术基础入门篇第8张Docker容器技术基础入门篇第36张
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker container run --help
Usage:    docker container run [OPTIONS] IMAGE [COMMAND] [ARG...]
Run a command ina new container
Options:
      --add-host list                  Add a custom host-to-IP mapping (host:ip)
  -a, --attach list                    Attach to STDIN, STDOUT or STDERR
      --blkio-weight uint16            Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)
      --blkio-weight-device list       Block IO weight (relative device weight) (default [])
      --cap-add list                   Add Linux capabilities
      --cap-drop list                  Drop Linux capabilities
      --cgroup-parent string           Optional parent cgroup forthe container
      --cidfile string                 Write the container ID to the file
      --cpu-period intLimit CPU CFS (Completely Fair Scheduler) period
      --cpu-quota intLimit CPU CFS (Completely Fair Scheduler) quota
      --cpu-rt-period int              Limit CPU real-time period inmicroseconds
      --cpu-rt-runtime int             Limit CPU real-time runtime inmicroseconds
  -c, --cpu-shares intCPU shares (relative weight)
      --cpus decimalNumber of CPUs
      --cpuset-cpus string             CPUs in which to allow execution (0-3, 0,1)
      --cpuset-mems string             MEMs in which to allow execution (0-3, 0,1)
  -d, --detach                         Run container inbackground and print container ID
      --detach-keys string             Override the key sequence fordetaching a container
      --device list                    Add a host device to the container
      --device-cgroup-rule list        Add a rule to the cgroup allowed devices list
      --device-read-bps list           Limit read rate (bytes per second) from a device (default [])
      --device-read-iops list          Limit read rate (IO per second) from a device (default [])
      --device-write-bps list          Limit writerate (bytes per second) to a device (default [])
      --device-write-iops list         Limit writerate (IO per second) to a device (default [])
      --disable-content-trust          Skip image verification (default true)
      --dns list                       Set custom DNS servers
      --dns-option list                Set DNS options
      --dns-search list                Set custom DNS search domains
      --entrypoint stringOverwrite the default ENTRYPOINT of the image
  -e, --envlist                       Set environment variables
      --env-file list                  Read in a fileof environment variables
      --expose list                    Expose a port or a range of ports
      --group-add list                 Add additional groups to join
      --health-cmd stringCommand to run to check health
      --health-interval duration       Time between running the check (ms|s|m|h) (default 0s)
      --health-retries intConsecutive failures needed to report unhealthy
      --health-start-period duration   Start period for the container to initialize before starting health-retries countdown (ms|s|m|h) (default 0s)
      --health-timeout duration        Maximum time to allow one check to run (ms|s|m|h) (default 0s)
      --help                           Print usage
  -h, --hostname stringContainer host name
      --init                           Run an init inside the container that forwards signals and reaps processes
  -i, --interactive                    Keep STDIN open even ifnot attached
      --ip string                      IPv4 address (e.g., 172.30.100.104)
      --ip6 string                     IPv6 address (e.g., 2001:db8::33)
      --ipc stringIPC mode to use
      --isolation stringContainer isolation technology
      --kernel-memory bytes            Kernel memory limit
  -l, --label list                     Set meta data on a container
      --label-file list                Read in a line delimited fileof labels
      --link list                      Add link to another container
      --link-local-ip list             Container IPv4/IPv6 link-local addresses
      --log-driver string              Logging driver forthe container
      --log-opt list                   Log driver options
      --mac-address string             Container MAC address (e.g., 92:d0:c6:0a:29:33)
  -m, --memory bytes                   Memory limit
      --memory-reservation bytes       Memory soft limit
      --memory-swap bytes              Swap limit equal to memory plus swap: '-1'to enable unlimited swap
      --memory-swappiness int          Tune container memory swappiness (0 to 100) (default -1)
      --mount mount                    Attach a filesystem mountto the container
      --name stringAssign a name to the container
      --network string                 Connect a container to a network (default "default")
      --network-alias list             Add network-scoped alias forthe container
      --no-healthcheck                 Disable any container-specified HEALTHCHECK
      --oom-kill-disable               Disable OOM Killer
      --oom-score-adj int              Tune host's OOM preferences (-1000 to 1000)
      --pid stringPID namespace to use
      --pids-limit int                 Tune container pids limit (set -1 forunlimited)
      --privileged                     Give extended privileges to this container
  -p, --publish list                   Publish a container's port(s) to the host
  -P, --publish-all                    Publish all exposed ports to random ports
      --read-only                      Mount the container's root filesystem as read only
      --restart string                 Restart policy to apply when a container exits (default "no")
      --rmAutomatically remove the container when it exits
      --runtime string                 Runtime to use forthis container
      --security-opt list              Security Options
      --shm-size bytes                 Size of /dev/shm
      --sig-proxy                      Proxy received signals to the process (default true)
      --stop-signal string             Signal to stop a container (default "SIGTERM")
      --stop-timeout int               Timeout (inseconds) to stop a container
      --storage-opt list               Storage driver options forthe container
      --sysctl map                     Sysctl options (default map[])
      --tmpfs list                     Mount a tmpfs directory
  -t, --tty                            Allocate a pseudo-TTY
      --ulimit ulimit                  Ulimit options (default [])
  -u, --user string                    Username or UID (format: <name|uid>[:<group|gid>])
      --userns stringUser namespace to use
      --uts stringUTS namespace to use
  -v, --volume list                    Bind mounta volume
      --volume-driver string           Optional volume driver forthe container
      --volumes-from list              Mount volumes from the specified container(s)
  -w, --workdir stringWorking directory inside the container
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker container run --help                      #查看帮助信息
Docker容器技术基础入门篇第8张Docker容器技术基础入门篇第38张
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker image pull centos:7
7: Pulling from library/centos
8ba884070f61: Pull complete 
Digest: sha256:8d487d68857f5bc9595793279b33d082b03713341ddec91054382641d14db861
Status: Downloaded newer image for centos:7
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker image pull centos:7                      #拉取一个centos7的镜像
Docker容器技术基础入门篇第8张Docker容器技术基础入门篇第40张
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker run  -it --name test-centos7 centos:7 /bin/bash
docker: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "process_linux.go:293: copying bootstrap data to pipe caused "write init-p: broken pipe"": unknown.
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# cat /etc/redhat-release 
CentOS Linux release 7.2.1511(Core) 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
不建议使用centos7.2,如果发现启动错误,可以更换centos7.6
Docker容器技术基础入门篇第8张Docker容器技术基础入门篇第42张
[root@node101.yinzhengjie.org.cn ~/Downloads]# 
[root@node101.yinzhengjie.org.cn ~/Downloads]# docker run  -it --name test centos:7 /bin/bash         
[root@d833df2d9ded /]# 
[root@d833df2d9ded /]# hostname
d833df2d9ded
[root@d833df2d9ded /]# 
[root@d833df2d9ded /]# cat /etc/redhat-release 
CentOS Linux release 7.6.1810(Core) 
[root@d833df2d9ded /]# 
[root@d833df2d9ded /]# exit 
exit
[root@node101.yinzhengjie.org.cn ~/Downloads]# 
[root@node101.yinzhengjie.org.cn ~/Downloads]# 
[root@node101.yinzhengjie.org.cn ~/Downloads]# cat /etc/redhat-release 
CentOS Linux release 7.6.1810(Core) 
[root@node101.yinzhengjie.org.cn ~/Downloads]# 
[root@node101.yinzhengjie.org.cn ~/Downloads]# docker run -it --name test centos:7 /bin/bash      #启动镜像,运行docker环境!
Docker容器技术基础入门篇第8张Docker容器技术基础入门篇第44张
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker run  -it --name test centos:7 /bin/bash
[root@d7a717a5f2fd /]# 
[root@d7a717a5f2fd /]# yum -y install net-tools
Loaded plugins: fastestmirror, ovl
Determining fastest mirrors
 *base: mirrors.nwsuaf.edu.cn
 *extras: mirrors.nwsuaf.edu.cn
 *updates: mirrors.nwsuaf.edu.cn
base                                                                                                                                                  | 3.6 kB  00:00:00
extras                                                                                                                                                | 3.4 kB  00:00:00
updates                                                                                                                                               | 3.4 kB  00:00:00
(1/4): base/7/x86_64/primary_db                                                                                                                       | 6.0 MB  00:00:00
(2/4): extras/7/x86_64/primary_db                                                                                                                     | 187 kB  00:00:04
(3/4): base/7/x86_64/group_gz                                                                                                                         | 166 kB  00:00:06
(4/4): updates/7/x86_64/primary_db                                                                                                                    | 3.4 MB  00:01:30
Resolving Dependencies
-->Running transaction check
---> Package net-tools.x86_64 0:2.0-0.24.20131004git.el7 will be installed
-->Finished Dependency Resolution
Dependencies Resolved
=============================================================================================================================================================================
 Package                                Arch                                Version                                                  Repository                         Size
=============================================================================================================================================================================
Installing:
 net-tools                              x86_64                              2.0-0.24.20131004git.el7                                 base                              306k
Transaction Summary
=============================================================================================================================================================================
Install  1Package
Total download size: 306k
Installed size: 918k
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/net-tools-2.0-0.24.20131004git.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for net-tools-2.0-0.24.20131004git.el7.x86_64.rpm is not installed
net-tools-2.0-0.24.20131004git.el7.x86_64.rpm                                                                                                         | 306 kB  00:00:00
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-6.1810.2.el7.centos.x86_64 (@CentOS)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : net-tools-2.0-0.24.20131004git.el7.x86_64                                                                                                                 1/1
  Verifying  : net-tools-2.0-0.24.20131004git.el7.x86_64                                                                                                                 1/1
Installed:
  net-tools.x86_64 0:2.0-0.24.20131004git.el7                                                                                                                                
Complete!
[root@d7a717a5f2fd /]# 
[root@d7a717a5f2fd /]# yum -y install net-tools                                  #在docker环境中使用net-tools工具
Docker容器技术基础入门篇第8张Docker容器技术基础入门篇第46张
[root@d7a717a5f2fd /]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.17.0.2  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:ac:11:00:02  txqueuelen 0(Ethernet)
        RX packets 3175  bytes 10682718 (10.1MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3174  bytes 174670 (170.5KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000(Local Loopback)
        RX packets 0  bytes 0 (0.0B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[root@d7a717a5f2fd /]# 
[root@d7a717a5f2fd /]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.17.0.1      0.0.0.0         UG    0      0        0eth0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0eth0
[root@d7a717a5f2fd /]# 
[root@d7a717a5f2fd /]# exit 
exit
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:c5:a1:05:86  txqueuelen 0(Ethernet)
        RX packets 3179  bytes 130434 (127.3KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3175  bytes 10682718 (10.1MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.30.1.101  netmask 255.255.255.0  broadcast 172.30.1.255
        ether 00:0c:29:fe:9b:ef  txqueuelen 1000(Ethernet)
        RX packets 148755  bytes 181214006 (172.8MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 48024  bytes 3569703 (3.4MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000(Local Loopback)
        RX packets 64  bytes 5792 (5.6KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 64  bytes 5792 (5.6KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[root@node101.yinzhengjie.org.cn ~]# 
[root@d7a717a5f2fd /]# ifconfig                                           #查看docker的网卡信息
Docker容器技术基础入门篇第8张Docker容器技术基础入门篇第48张
[root@node101.yinzhengjie.org.cn ~]# iptables -t nat -vnL
Chain PREROUTING (policy ACCEPT 54 packets, 3711bytes)
 pkts bytes target     prot opt inout     source               destination         
    0     0 DOCKER     all  --  *      *       0.0.0.0/0            0.0.0.0/0            ADDRTYPE match dst-type LOCAL
Chain INPUT (policy ACCEPT 2 packets, 464bytes)
 pkts bytes target     prot opt inout     source               destination         
Chain OUTPUT (policy ACCEPT 79 packets, 5930bytes)
 pkts bytes target     prot opt inout     source               destination         
    0     0 DOCKER     all  --  *      *       0.0.0.0/0           !127.0.0.0/8          ADDRTYPE match dst-type LOCAL
Chain POSTROUTING (policy ACCEPT 79 packets, 5930bytes)
 pkts bytes target     prot opt inout     source               destination         
   52  3247 MASQUERADE  all  --  *      !docker0  172.17.0.0/16        0.0.0.0/0
Chain DOCKER (2references)
 pkts bytes target     prot opt inout     source               destination         
    0     0 RETURN     all  --  docker0 *       0.0.0.0/0            0.0.0.0/0
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# iptables -t nat -vnL                          #启动docker后,我们可以在iptables命令中看到他默认加了很多规则
Docker容器技术基础入门篇第8张Docker容器技术基础入门篇第50张
[root@node101.yinzhengjie.org.cn ~]# iptables -t filter -vnL
Chain INPUT (policy ACCEPT 26257packets, 98M bytes)
 pkts bytes target     prot opt inout     source               destination         
Chain FORWARD (policy DROP 0 packets, 0bytes)
 pkts bytes target     prot opt inout     source               destination         
 5751 9807K DOCKER-USER  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
 5751 9807K DOCKER-ISOLATION-STAGE-1  all  --  *      *       0.0.0.0/0            0.0.0.0/0           
 2885 9689K ACCEPT     all  --  *      docker0  0.0.0.0/0            0.0.0.0/0ctstate RELATED,ESTABLISHED
    0     0 DOCKER     all  --  *      docker0  0.0.0.0/0            0.0.0.0/0           
 2866  118K ACCEPT     all  --  docker0 !docker0  0.0.0.0/0            0.0.0.0/0           
    0     0 ACCEPT     all  --  docker0 docker0  0.0.0.0/0            0.0.0.0/0
Chain OUTPUT (policy ACCEPT 25740packets, 1159K bytes)
 pkts bytes target     prot opt inout     source               destination         
Chain DOCKER (1references)
 pkts bytes target     prot opt inout     source               destination         
Chain DOCKER-ISOLATION-STAGE-1 (1references)
 pkts bytes target     prot opt inout     source               destination         
 2866  118K DOCKER-ISOLATION-STAGE-2  all  --  docker0 !docker0  0.0.0.0/0            0.0.0.0/0           
 5751 9807K RETURN     all  --  *      *       0.0.0.0/0            0.0.0.0/0
Chain DOCKER-ISOLATION-STAGE-2 (1references)
 pkts bytes target     prot opt inout     source               destination         
    0     0 DROP       all  --  *      docker0  0.0.0.0/0            0.0.0.0/0           
 2866  118K RETURN     all  --  *      *       0.0.0.0/0            0.0.0.0/0
Chain DOCKER-USER (1references)
 pkts bytes target     prot opt inout     source               destination         
 5751 9807K RETURN     all  --  *      *       0.0.0.0/0            0.0.0.0/0
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# iptables -t filter -vnL

5>.查看docker容器的运行状态

Docker容器技术基础入门篇第8张Docker容器技术基础入门篇第52张
[root@node101.yinzhengjie.org.cn ~]# docker ps -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                       PORTS               NAMES
20f52b7776da        centos:7            "/bin/bash"         12 seconds ago      Up 10seconds                                    test2
d7a717a5f2fd        centos:7            "/bin/bash"         7 minutes ago       Exited (127) 5minutes ago                       test
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker ps -a              #查看所有的容器状况
Docker容器技术基础入门篇第8张Docker容器技术基础入门篇第54张
[root@node101.yinzhengjie.org.cn ~]# docker container ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
20f52b7776da        centos:7            "/bin/bash"         55 seconds ago      Up 54seconds                           test2
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker  ps
CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS              PORTS               NAMES
20f52b7776da        centos:7            "/bin/bash"About a minute ago   Up About a minute                       test2
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# 
[root@node101.yinzhengjie.org.cn ~]# docker container ps          #仅查看正在运行的容器

免责声明:文章转载自《Docker容器技术基础入门篇》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇cheap-source-map--不显示源码 、source-map--显示源码 、 eval--最快的编译办法Git客户端TortoiseGit(Windows系统)的使用方法下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

随便看看

ArcGIS地图打印设置

业务流程是首先框定要打印的地图范围,这是一个自定义大小。选择帧后,预览帧,然后选择打印输出。在打印输出界面中设置后,HP绘图仪将打印地图。因此,确定该问题与ArcGIS无关,属于打印地图设置问题。...

Matlab高级教程_第二篇:Matlab相见恨晚的模块_02_并行运算-1

3 MATLAB2009之后,并行计算工具箱和并行计算服务退出。通过PCT和DCS,用户可以实现基于多核平台、多处理器平台和集群平台的多个并行计算任务。除了支持上述通用功能外,PCT还增加了对GPU单元的支持。现在来看彼此已经太晚了:用parfor并行化for循环。在编程中,使计算量最小化的代码总是一个循环。7 parpool命令在不启动并行池的情况下配置并...

数据不平衡的相关

大多数常见的机器学习算法不能很好地处理不平衡的数据集。例如,搜索引擎的点击预测(点击页面往往占很小的比例)、电子商务中的产品推荐(正在购买的推荐产品的比例很低)、信用卡欺诈检测、网络攻击识别、癌症检测等。处理数据不平衡的方法主要有以下几种。2.数据级别2.1重新采样2.1.1欠采样(下采样)欠采样通过减少丰富类的大小来平衡数据集。它试图通过增加稀有样本的数量...

Idea常用插件整合

官方网站:https://plugins.jetbrains.com/plugin/228-sql-query-plugin6.IdeaVim基于IntelliJ的Vim仿真插件。注意:如果打开WebInspector,那么CSS/JavaScript同步和元素高亮显示不起作用“pluginisdebuggingthistab”信息栏的可用性问题官方网站:h...

flutter vscode+第三方安卓模拟器

1.首先打开夜曲模拟器2.Win+R,选择cmd,在第三方模拟器安装目录的bin目录下输入夜曲模拟器,然后运行命令:nox_Adb.execonnect127.0.0.1:620013。打开项目终端的vscode并建立连接:adbconnect127.00.1:62001(夜神模拟器的默认端口)4。查看连接:adbdevices或不使用第三方模拟器:1.打开...

HTML中canvas的大小调整

今天用到canvas元素,发现它的大小不是像普通dom元素一样,直接设置css样式可以改变的,它会由自己原本的大小伸缩。例如,1.如果直接在canvas元素中添加style='300px;height:300px',这会导致伸缩,如图2.换种方式在css样式表中加入样式设置宽高产生的效果也是一样的。...