文档章节

高性能容器伺服器-containerd简介

openthings
 openthings
发布于 2016/12/12 08:43
字数 1078
阅读 131
收藏 3

containerd是一个高性能的容器(container)伺服系统(查看源码),部分功能与Docker很像,相当于Docker Daemon模式和更新版的DockerD。

  • containerd采用并行启动技术,可以每秒启动上百个容器实例。containerd提供命令行和REST服务接口,里面对容器真正的管理是通过containerd-shim进程来完成
  • 与Docker Engine的一锅烩模式不同的是,containerd并不管理容器的镜像,主要支持OCI(https://www.opencontainers.org/)开放容器标准的镜像,通过runc来启动。
  • OCI镜像可以通过Docker镜像转换而来(参见:https://github.com/docker/containerd/blob/master/docs/bundle.md)。

containerd与大家熟知的Docker可谓相生相克,最新发展出的关系如下图所示。

  • Docker从1.11开始,已经支持containerd和runc来运行容器。在DockerD服务启动时自动启动了containerd作为后台进程服务(可以通过ps aux | grep docker查看)。
  • 更详细的中文介绍参考:http://dockone.io/article/1327 。

 

下面是containerd的官方介绍,原文:https://containerd.tools/

About containerd

Containerd is a daemon with an API and a command line client, to manage containers on one machine. It uses runC to run containers according to the OCI specification. Containerd has advanced features such as seccomp and user namespace support as well as checkpoint and restore for cloning and live migration of containers. The code can be found on Github. Containerd is currently available as an alpha release.

Built for Performance

Starting 1000 containers concurrently runs at 126-140 containers per second.

Easy to use

Containerd provides a daemon and a command line client to manage containers.

Battle Hardened

Containerd is built on runC, the same container technology powering millions of Docker Engine installations.

Compatible with Docker

Docker images can be run with containerd.

 

Getting Started

Daemon options

$ containerd -h

NAME:
   containerd - High performance container daemon

USAGE:
   containerd [global options] command [command options] [arguments...]

VERSION:
   0.0.4

AUTHOR(S): 
   @crosbymichael <crosbymichael@gmail.com> 

COMMANDS:
   help, h  Shows a list of commands or help for one command
   
GLOBAL OPTIONS:
   --id "deathstar"                 unique containerd id to identify the instance
   --debug                      enable debug output in the logs
   --state-dir "/run/containerd"            runtime state directory
   -c, --concurrency "10"               set the concurrency level for tasks
   --metrics-interval "1m0s"                interval for flushing metrics to the store
   --listen, -l "/run/containerd/containerd.sock"   Address on which GRPC API will listen
   --oom-notify                     enable oom notifications for containers
   --help, -h                       show help
   --version, -v                    print the version
   

GRPC API

The API for containerd is with GRPC over a unix socket located at the default location of /run/containerd/containerd.sock.

At this time please refer to the proto definition for the API methods and types.
There is a Go implementation and types checked into this repository but alternate language implementations can be created using the grpc and protoc toolchain.

containerd CLI

There is a default cli named ctr based on the GRPC api. This cli will allow you to create and manage containers run with containerd.

NAME:
   ctr - High performance container daemon controller

USAGE:
   ctr [global options] command [command options] [arguments...]

VERSION:
   0.0.4

AUTHOR(S): 
   @crosbymichael <crosbymichael@gmail.com> 

COMMANDS:
   checkpoints  list all checkpoints
   containers   interact with running containers
   events   receive events from the containerd daemon
   help, h  Shows a list of commands or help for one command
   
GLOBAL OPTIONS:
   --debug                  enable debug output in the logs
   --address "/run/containerd/containerd.sock"  address of GRPC API
   --help, -h                   show help
   --version, -v                print the version
   

Listing containers

$ sudo ctr containers
ID                  PATH                STATUS              PID1
1                   /containers/redis   running             14063
19                  /containers/redis   running             14100

Starting a container

$ ctr containers start -h
NAME:
   start - start a container

USAGE:
   command start [command options] [arguments...]

OPTIONS:
   --checkpoint, -c     checkpoint to start the container from
   --attach, -a         connect to the stdio of the container

$ sudo ctr containers start redis /containers/redis

Kill a container’s process

$ ctr containers kill -h 
NAME:
   kill - send a signal to a container or it's processes

USAGE:
   command kill [command options] [arguments...]

OPTIONS:
   --pid, -p "0"        pid of the process to signal within the container
   --signal, -s "15"    signal to send to the container

Exec another process into a container

$ ctr containers exec -h 
NAME:
   exec - exec another process in an existing container

USAGE:
   command exec [command options] [arguments...]

OPTIONS:
   --id                                         container id to add the process to
   --attach, -a                                 connect to the stdio of the container
   --cwd                                        current working directory for the process
   --tty, -t                                    create a terminal for the process
   --env, -e [--env option --env option]        environment variables for the process
   --uid, -u "0"                                user id of the user for the process
   --gid, -g "0"                                group id of the user for the process
   

Stats for a container

$ ctr containers stats -h 
NAME:
   stats - get stats for running container

USAGE:
  command stats [arguments...]

List checkpoints

$ sudo ctr checkpoints redis
NAME                TCP                 UNIX SOCKETS        SHELL
test                false               false               false
test2               false               false               false

Create a new checkpoint

$ ctr checkpoints create -h
NAME:
   create - create a new checkpoint for the container

USAGE:
   command create [command options] [arguments...]

OPTIONS:
   --tcp                persist open tcp connections
   --unix-sockets       perist unix sockets
   --exit               exit the container after the checkpoint completes successfully
   --shell              checkpoint shell jobs
   

Get events

$ sudo ctr events
TYPE                ID                  PID                 STATUS
exit                redis               24761               0

Performance

Starting 1000 containers concurrently runs at 126-140 containers per second.

Overall start times:

[containerd] 2015/12/04 15:00:54   count:        1000
[containerd] 2015/12/04 14:59:54   min:          23ms
[containerd] 2015/12/04 14:59:54   max:         355ms
[containerd] 2015/12/04 14:59:54   mean:         78ms
[containerd] 2015/12/04 14:59:54   stddev:       34ms
[containerd] 2015/12/04 14:59:54   median:       73ms
[containerd] 2015/12/04 14:59:54   75%:          91ms
[containerd] 2015/12/04 14:59:54   95%:         123ms
[containerd] 2015/12/04 14:59:54   99%:         287ms
[containerd] 2015/12/04 14:59:54   99.9%:       355ms

© 著作权归作者所有

共有 人打赏支持
openthings
粉丝 278
博文 1031
码字总数 561308
作品 1
东城
架构师
私信 提问
Docker发布 LinuxKit 和 Moby 开源项目

  【IT168 评论】在一年一度的DockerCon大会上,来自全球各地的 5000 名参与者,济济一堂,于奥斯丁会议中心,共同见证 Docker 的发展,探讨容器技术的落地。   Docker创办人暨技术长Sol...

it168网站
2017/04/20
0
0
Containerd给Kubernetes带来了更多容器运行时的可选方案

容器运行时是在某个节点上执行容器并且管理容器镜像的软件。如今,最广为人知的容器运行时是Docker,但是,生态系统内也有一些别的容器运行时,比如rkt,containerd和Ixd。Docker是目前为止在...

Docker
02/20
0
0
Kubernetes Containerd集成进入GA阶段

在之前的博客Containerd给Kubernetes带来更多的容器运行选项[1],我们介绍了Kubernetes containerd integration的内部测试版。经历了6个月的开发,正式版推出了!现在,你可以在生产环境的K...

m2l0zgssvc7r69efdtj
05/29
0
0
Kubernetes1.7新特性:支持绕过Docker,直接通过Containerd管理容器

背景情况 从Docker1.11版本开始,Docker依赖于containerd和runC来管理容器,containerd是控制runC的后台程序,runC是docker公司按照OCI标准规范编写的一个操作容器的命令行工具,containerd这...

店家小二
12/14
0
0
控制 runC 的守护进程--Containerd

Containerd 是一个控制 runC 的守护进程,主要是为了性能和密度。Containerd 提供一个命令行客户端和 API,在一个机器上管理容器。Containerd 使用 runC 来根据 OCI 规范运行容器 。 Contai...

叶秀兰
2015/12/18
2K
0

没有更多内容

加载失败,请刷新页面

加载更多

Spring AOP 切面编程记录日志和接口执行时间

最近客户现在提出系统访问非常慢,需要优化提升访问速度,在排查了nginx、tomcat内存和服务器负载之后,判断是数据库查询速度慢,进一步排查发现是因为部分视图和表查询特别慢导致了整个系统...

编程SHA
18分钟前
5
0
年度大盘点:机器学习开源项目及框架

摘要: 2018年马上就要结束了,我们来回顾一下过去的这一年中,机器学习领域有哪些有趣的事情吧! 我们先来看看Mybridge AI 中排名靠前的顶级开源项目,再聊聊机器学习今年都有哪些发展,最后...

阿里云官方博客
21分钟前
4
0
15个Spring的核心注释示例

众所周知,Spring DI和Spring IOC是Spring Framework的核心概念。让我们从org.springframework.beans.factory.annotation和org.springframework.context.annotation包中探索一些Spring核心注......

java菜分享
23分钟前
0
0
[LintCode] Binary Tree Level Order Traversal(二叉树的层次遍历)

描述 给出一棵二叉树,返回其节点值的层次遍历(逐层从左往右访问) 样例 给一棵二叉树 {3,9,20,#,#,15,7} : 3 / \9 20 / \ 15 7 返回他的分层遍历结果: [ [3], [...

honeymose
32分钟前
2
0
renderer

renderer Function 单元格绘制处理函数,同drawcell事件。

architect刘源源
52分钟前
6
1

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部