containerd/containerd

Name: containerd

Owner: containerd

Description: An open and reliable container runtime

Created: 2015-11-13 00:27:43.0

Updated: 2018-01-18 18:54:50.0

Pushed: 2018-01-18 19:34:52.0

Homepage: https://containerd.io

Size: 39379

Language: Go

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

banner

GoDoc Build Status FOSSA Status Go Report Card CII Best Practices

containerd is an industry-standard container runtime with an emphasis on simplicity, robustness and portability. It is available as a daemon for Linux and Windows, which can manage the complete container lifecycle of its host system: image transfer and storage, container execution and supervision, low-level storage and network attachments, etc.

containerd is designed to be embedded into a larger system, rather than being used directly by developers or end-users.

architecture

Getting Started

See our documentation on containerd.io:

See how to build containerd from source at BUILDING.

If you are interested in trying out containerd see our example at Getting Started.

Runtime Requirements

Runtime requirements for containerd are very minimal. Most interactions with the Linux and Windows container feature sets are handled via runc and/or OS-specific libraries (e.g. hcsshim for Microsoft). The current required version of runc is always listed in RUNC.md.

There are specific features used by containerd core code and snapshotters that will require a minimum kernel version on Linux. With the understood caveat of distro kernel versioning, a reasonable starting point for Linux is a minimum 4.x kernel version.

The overlay filesystem snapshotter, used by default, uses features that were finalized in the 4.x kernel series. If you choose to use btrfs, there may be more flexibility in kernel version (minimum recommended is 3.18), but will require the btrfs kernel module and btrfs tools to be installed on your Linux distribution.

To use Linux checkpoint and restore features, you will need criu installed on your system. See more details in Checkpoint and Restore.

Build requirements for developers are listed in BUILDING.

Features
Client

containerd offers a full client package to help you integrate containerd into your platform.

rt (
ithub.com/containerd/containerd"
ithub.com/containerd/containerd/cio"



 main() {
client, err := containerd.New("/run/containerd/containerd.sock")
defer client.Close()

Namespaces

Namespaces allow multiple consumers to use the same containerd without conflicting with each other. It has the benefit of sharing content but still having separation with containers and images.

To set a namespace for requests to the API:

ext = context.Background()
reate a context for docker
er = namespaces.WithNamespace(context, "docker")

ainerd, err := client.NewContainer(docker, "id")

To set a default namespace on the client:

nt, err := containerd.New(address, containerd.WithDefaultNamespace("docker"))
Distribution
ull an image
e, err := client.Pull(context, "docker.io/library/redis:latest")

ush an image
:= client.Push(context, "docker.io/library/redis:latest", image.Target())
Containers

In containerd, a container is a metadata object. Resources such as an OCI runtime specification, image, root filesystem, and other metadata can be attached to a container.

s, err := client.NewContainer(context, "redis-master")
r redis.Delete(context)
OCI Runtime Specification

containerd fully supports the OCI runtime specification for running containers. We have built in functions to help you generate runtime specifications based on images as well as custom parameters.

You can specify options when creating a container about how to modify the specification.

s, err := client.NewContainer(context, "redis-master", containerd.WithNewSpec(oci.WithImageConfig(image)))
Root Filesystems

containerd allows you to use overlay or snapshot filesystems with your containers. It comes with builtin support for overlayfs and btrfs.

ull an image and unpack it into the configured snapshotter
e, err := client.Pull(context, "docker.io/library/redis:latest", containerd.WithPullUnpack)

llocate a new RW root filesystem for a container based on the image
s, err := client.NewContainer(context, "redis-master",
containerd.WithNewSnapshot("redis-rootfs", image),
containerd.WithNewSpec(oci.WithImageConfig(image)),


se a readonly filesystem with multiple containers
i := 0; i < 10; i++ {
id := fmt.Sprintf("id-%s", i)
container, err := client.NewContainer(ctx, id,
    containerd.WithNewSnapshotView(id, image),
    containerd.WithNewSpec(oci.WithImageConfig(image)),
)

Tasks

Taking a container object and turning it into a runnable process on a system is done by creating a new Task from the container. A task represents the runnable object within containerd.

reate a new task
, err := redis.NewTask(context, cio.Stdio)
r task.Delete(context)

he task is now running and has a pid that can be use to setup networking
r other runtime settings outside of containerd
:= task.Pid()

tart the redis-server process inside the container
:= task.Start(context)

ait for the task to exit and get the exit status
us, err := task.Wait(context)
Checkpoint and Restore

If you have criu installed on your machine you can checkpoint and restore containers and their tasks. This allow you to clone and/or live migrate containers to other machines.

heckpoint the task then push it to a registry
kpoint, err := task.Checkpoint(context, containerd.WithExit)

:= client.Push(context, "myregistry/checkpoints/redis:master", checkpoint)

n a new machine pull the checkpoint and restore the redis container
e, err := client.Pull(context, "myregistry/checkpoints/redis:master")

kpoint := image.Target()

s, err = client.NewContainer(context, "redis-master", containerd.WithCheckpoint(checkpoint, "redis-rootfs"))
r container.Delete(context)

, err = redis.NewTask(context, cio.Stdio, containerd.WithTaskCheckpoint(checkpoint))
r task.Delete(context)

:= task.Start(context)
Releases and API Stability

Please see RELEASES.md for details on versioning and stability of containerd components.

Development reports.

Weekly summary on the progress and what is being worked on. https://github.com/containerd/containerd/tree/master/reports

Communication

For async communication and long running discussions please use issues and pull requests on the github repo. This will be the best place to discuss design and implementation.

For sync communication we have a community slack with a #containerd channel that everyone is welcome to join and chat about development.

Slack: https://dockr.ly/community

Reporting security issues

If you are reporting a security issue, please reach out discreetly at security@containerd.io.

Licenses

The containerd codebase is released under the Apache 2.0 license. The README.md file, and files in the “docs” folder are licensed under the Creative Commons Attribution 4.0 International License under the terms and conditions set forth in the file “LICENSE.docs“. You may obtain a duplicate copy of the same license, titled CC-BY-4.0, at http://creativecommons.org/licenses/by/4.0/.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.