Docker容器:关键技术

发布于 2017-03-28 · 本文总共 2013 字 · 阅读大约需要 6 分钟

Docker架构

Docker架构

docker_architechture

Docker Daemon

Docker Daemon是一个常驻后台的系统进程,是整个Docker功能的核心引擎;

Docker守护进程(dockerd)监听API请求同时负责管理所有Docker对象,包括镜像、容器、网络、存储等对象; 一个Docker daemon也会和其他daemons通信来管理Docker services;

Docker client

用户通过Docker客户端和Docker交互;当使用docker命令行如docker run时,客户端将命令传递给dockerd,dockerd实现相应的功能之后返回结果给客户端;

一个Docker客户端可以和多个daemon通信;

Docker Registry

存储Docker镜像;Docker Hub是默认的官方镜像仓库;当然也可以配置为私人的仓库;

使用docker pull或者docker run命令将会从镜像仓库中拉取镜像;

docker push命令可以将镜像推送到配置的镜像仓库;

Docker对象

Docker镜像–images

通常会使用Dockerfile来创建Docker Image,这是一个定制镜像内容的配置文件,同时也能在内容上体现层级关系;

Docker容器–containers

运行中的images实例,提供了一个完整的、隔离状态的运行环境; 可以使用命令create、start、stop、move、delete来操作容器;

一个容器由镜像和启动容器时的配置选项来定义;当容器被删除时,对其状态的变更不会被保存;

services

Services allow you to scale containers across multiple Docker daemons, which all work together as a swarm with multiple managers and workers. Each member of a swarm is a Docker daemon, and all the daemons communicate using the Docker API. A service allows you to define the desired state, such as the number of replicas of the service that must be available at any given time. By default, the service is load-balanced across all worker nodes. To the consumer, the Docker service appears to be a single application. Docker Engine supports swarm mode in Docker 1.12 and higher.

底层技术

Docker使用Go语言实现;基于Linux内核的一些特性实现其功能;

Namespaces

Docker使用namespaces技术来实现容器的隔离;当你启动一个容器的时候,Docker创建一系列的namespaces,包括:

pid namespaces:进程隔离;PID: Process ID

net namespaces:网络隔离;NET: Networking

ipc namespaces:系统消息队列隔离;IPC: InterProcess Communication

mnt namespaces:文件系统挂载点隔离;MNT: Mount

uts namespaces: 内核和版本标识隔离;UTS: Unix Timesharing System

Control groups

使用cgroups技术来限制应用对资源的访问; cgroups允许Docker引擎在容器间进行硬件资源共享以及随时进行限制和约束;

Union file systems

联合文件系统,是一种通过分层技术实现的轻量化和高性能的文件系统;Union file systems, or UnionFS, are file systems that operate by creating layers, making them very lightweight and fast.

联合文件系统支持将文件的修改作为一次提交来一层一层的叠加,同时将不同的目录挂载到 同一个虚拟文件系统下;

不同Docker容器可以共享一些基础文件系统层,与自己独有的改动层一起使用,可以 大大提高存储效率;

Docker目前支持的联合文件系统包括AUFS、btrfs、vfs、DeviceMapper;

Container format

Docker容器引擎将Namespaces、cgroups和UnionFS组合成一个叫容器格式的整体; 当前默认的容器格式是libcontainer,未来Docker可能通过与其他技术,如BSD Jails或Solaris Zones 的集成来开发其他的容器格式;

refs

https://docs.docker.com/get-started/overview/




本博客所有文章采用的授权方式为 自由转载-非商用-非衍生-保持署名 ,转载请务必注明出处,谢谢。
声明:
本博客欢迎转发,但请保留原作者信息!
博客地址:邱文奇(qiuwenqi)的博客;
内容系本人学习、研究和总结,如有雷同,实属荣幸!
阅读次数:

文章评论

comments powered by Disqus


章节列表