Go to file
Sebastiaan van Stijn 0a7fd55f32
sys: deprecate EpollCreate1, EpollCtl, EpollWait
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-03-09 13:15:07 +01:00
.github Update Golang 1.13.8 2020-02-17 17:18:25 +01:00
.zuul/playbooks/containerd-build ci: set pipefail in zuul script 2020-01-08 13:50:20 +08:00
api vendor protobuf & grpc 2020-02-26 10:57:05 +09:00
archive Fix build with gccgo 2020-01-07 19:28:26 +08:00
cio vendor: update gotest.tools v3.0.2 2020-02-28 17:47:20 +01:00
cmd Support NOTIFY_SOCKET 2020-03-07 10:24:51 -08:00
containers fix-grammar-mistake 2019-08-28 16:10:08 +08:00
content vendor: update gotest.tools v3.0.2 2020-02-28 17:47:20 +01:00
contrib Update Golang 1.13.8 2020-02-17 17:18:25 +01:00
defaults Remove windows v1 runtime 2019-07-23 18:54:37 +00:00
design Remove outdated plugin design doc 2018-07-25 23:28:09 -07:00
diff apply: use naive applier when running in UserNS 2019-10-24 13:33:09 +09:00
docs Fix startup_delay within default configuration 2020-01-29 15:34:23 +02:00
errdefs Add support to gRPC errdefs for context cancel/deadline exceeded 2019-05-28 17:02:29 -07:00
events Use common identifiers package with less restrictive regex 2019-11-04 21:22:01 -05:00
filters Merge pull request #3942 from hs0210/work 2020-02-18 12:05:22 -08:00
gc vendor: update gotest.tools v3.0.2 2020-02-28 17:47:20 +01:00
identifiers Clarify requirements for identifiers validation 2019-11-04 21:22:10 -05:00
images Replace ocispec.MediaTypeImageManifest with manifest.MediaType 2019-12-20 10:26:13 +08:00
labels Licence header added 2018-02-19 10:32:26 +09:00
leases leases: support resource management 2019-05-29 11:00:32 +08:00
log vendor: update gotest.tools v3.0.2 2020-02-28 17:47:20 +01:00
metadata Add Cleanup to snapshot API 2020-01-07 14:59:20 -08:00
metrics export cgroups collectors 2020-03-06 12:51:22 -05:00
mount vendor: update gotest.tools v3.0.2 2020-02-28 17:47:20 +01:00
namespaces Use common identifiers package with less restrictive regex 2019-11-04 21:22:01 -05:00
oci Add linux resource oci.SpecOpts 2020-03-05 13:02:10 -05:00
pkg vendor: update gotest.tools v3.0.2 2020-02-28 17:47:20 +01:00
platforms Support 32-bit userspace on 64-bit ARM cores 2020-02-13 00:10:01 -05:00
plugin Fix build with gccgo 2020-01-07 19:28:26 +08:00
protobuf/plugin vendor protobuf & grpc 2020-02-26 10:57:05 +09:00
reference Fix panic on reference.Spec.Hostname() 2019-11-11 13:53:31 +08:00
releases Fix broken link to release-tool 2020-01-28 14:57:31 +01:00
remotes vendor: update gotest.tools v3.0.2 2020-02-28 17:47:20 +01:00
reports Perfect documentation 2019-09-25 16:59:31 +08:00
rootfs Do not loose snapshotter options 2020-03-02 13:48:41 -08:00
runtime Avoid allocating slice for finding Process 2020-03-06 09:51:26 -08:00
script vendor protobuf & grpc 2020-02-26 10:57:05 +09:00
services vendor: update gotest.tools v3.0.2 2020-02-28 17:47:20 +01:00
snapshots Pass snapshotter opts during Pull 2020-03-02 13:45:40 -08:00
sys sys: deprecate EpollCreate1, EpollCtl, EpollWait 2020-03-09 13:15:07 +01:00
vendor Merge pull request #4088 from mxpv/sd 2020-03-08 15:49:26 +09:00
version version: use runtime.Version() directly 2019-10-07 22:45:26 +08:00
.appveyor.yml AppVeyor: disable download progress on choco installs 2020-02-27 12:03:06 +01:00
.gitignore Add capability to build manpages from markdown 2018-01-30 19:50:45 -05:00
.golangci.yml Move golangci-lint deadline to config file 2019-09-19 09:10:56 -04:00
.mailmap Update .mailmap 2020-02-18 10:24:08 +01:00
.travis.yml Update Golang 1.13.8 2020-02-17 17:18:25 +01:00
.zuul.yaml Add OpenLab CI configuration 2019-05-08 17:21:41 +08:00
ADOPTERS.md Add more adopters to ADOPTERS.md 2019-12-20 11:27:50 -05:00
benchmark_test.go Add testing log context 2019-07-16 10:31:43 -07:00
BUILDING.md vendor protobuf & grpc 2020-02-26 10:57:05 +09:00
client_opts.go Pass snapshotter opts during Pull 2020-03-02 13:45:40 -08:00
client_test.go Move flag.Parse in tests to TestMain 2019-10-11 13:27:54 -04:00
client_ttrpc_test.go vendor: update gotest.tools v3.0.2 2020-02-28 17:47:20 +01:00
client_unix_test.go Update the integration test. 2019-08-21 16:31:29 -07:00
client_windows_test.go Convert Windows CI to use Microsoft MCR image urls 2019-04-18 16:07:00 -07:00
client.go Pass snapshotter opts during Pull 2020-03-02 13:45:40 -08:00
code-of-conduct.md Add code of conduct 2017-04-04 09:41:38 -07:00
container_checkpoint_opts.go Copy annotations around where necessary 2019-03-06 12:26:23 -05:00
container_checkpoint_test.go Add testing log context 2019-07-16 10:31:43 -07:00
container_linux_test.go Split uid and gid user ns remapping in oci 2019-12-10 03:07:50 -06:00
container_opts_unix.go Support configurable default platform in the client. 2019-09-03 13:34:25 -07:00
container_opts.go Support configurable default platform in the client. 2019-09-03 13:34:25 -07:00
container_restore_opts.go Support configurable default platform in the client. 2019-09-03 13:34:25 -07:00
container_test.go Fix container pid. 2019-12-02 01:02:22 -08:00
container.go Use spec's mountLabel when mounting the rootfs 2020-02-24 10:04:05 -07:00
containerd.service Support NOTIFY_SOCKET 2020-03-07 10:24:51 -08:00
containerstore.go Add containers streaming API 2018-07-26 13:55:20 -04:00
content_test.go Fix cleanup error on content client test 2019-11-26 11:22:35 -08:00
daemon_config_linux_test.go Don't search for state.json path 2019-09-20 14:35:58 -04:00
daemon_test.go linux: fix runtime-root propagation 2018-03-05 15:01:22 +09:00
diff.go Add unpack opts 2019-08-07 18:35:55 +00:00
events.go bugfix: return the context error during event subscribe 2018-10-24 19:25:57 +08:00
export_test.go Add testing log context 2019-07-16 10:31:43 -07:00
export.go Update image export to support Docker format 2019-04-04 15:23:06 -07:00
grpc.go Switch from x/net/context to context 2018-04-24 14:33:34 -07:00
helpers_unix_test.go Licence header added 2018-02-19 10:32:26 +09:00
helpers_windows_test.go Licence header added 2018-02-19 10:32:26 +09:00
image_store.go Copy annotations around where necessary 2019-03-06 12:26:23 -05:00
image_test.go cleanup the image synchronously for Usage case 2020-02-22 00:02:33 +08:00
image.go Return the underlying images metadata 2019-12-04 13:03:41 -05:00
import_test.go Remove an empty line 2019-12-20 17:19:41 +08:00
import.go Support configurable default platform in the client. 2019-09-03 13:34:25 -07:00
install_opts.go Add optional install path 2018-09-11 10:36:00 -04:00
install.go create local version of introspection service 2020-01-02 12:34:23 -08:00
lease_test.go Add testing log context 2019-07-16 10:31:43 -07:00
lease.go Make client's WithLease more flexible. 2019-10-04 12:22:16 -07:00
LICENSE Edit Containerd license info so GitHub recognizes it 2018-04-02 12:31:15 -07:00
Makefile Add Makefile variable to skip test packages 2020-01-07 15:25:05 -08:00
Makefile.darwin Licence header added 2018-02-19 10:32:26 +09:00
Makefile.freebsd Licence header added 2018-02-19 10:32:26 +09:00
Makefile.linux mips: -buildmode=pie is not supported for the mips arch 2019-11-06 12:50:58 +01:00
Makefile.windows Better support windows binaries. 2019-11-12 11:52:49 -08:00
namespaces.go Add cgroup delete opt for ns deletion 2019-07-01 15:01:02 -04:00
NOTICE Update readme and documentation for release 2015-12-16 12:15:22 -08:00
PLUGINS.md Document plugins 2018-07-25 23:28:09 -07:00
process.go Word spelling correction 2019-09-25 16:49:54 +08:00
Protobuild.toml Add proto path /usr/include to Protobuild 2019-11-07 14:36:54 -05:00
pull.go Pass snapshotter opts during Pull 2020-03-02 13:45:40 -08:00
README.md Fix reference to LICENSE in README.md 2020-02-13 00:10:49 -05:00
RELEASES.md RELEASES.md: update release status 2020-03-06 10:29:39 +08:00
ROADMAP.md Update roadmap.md with issue labels and milestones 2018-01-04 10:47:06 -05:00
RUNC.md fix RUNC.md vs vendor.conf mismatch 2018-05-11 13:56:54 +09:00
SCOPE.md Update readme 2017-06-20 13:19:53 -07:00
services.go create local version of introspection service 2020-01-02 12:34:23 -08:00
signals_test.go Use unix.SignalNum in ParseSignal on unix platform 2019-03-03 22:10:58 +08:00
signals_unix.go Use unix.SignalNum in ParseSignal on unix platform 2019-03-03 22:10:58 +08:00
signals_windows.go Use unix.SignalNum in ParseSignal on unix platform 2019-03-03 22:10:58 +08:00
signals.go Use unix.SignalNum in ParseSignal on unix platform 2019-03-03 22:10:58 +08:00
snapshot_test.go Licence header added 2018-02-19 10:32:26 +09:00
snapshotter_default_linux.go Licence header added 2018-02-19 10:32:26 +09:00
snapshotter_default_unix.go enable native (formerly naive) snapshotter by default 2018-04-02 13:29:19 +09:00
snapshotter_default_windows.go Licence header added 2018-02-19 10:32:26 +09:00
task_opts_unix_test.go move WithXXXX to task_opts.go 2018-09-10 15:24:01 +08:00
task_opts_unix.go support user remapping in ctr 2019-12-12 01:16:47 -06:00
task_opts.go Merge pull request #3000 from stefanberger/descriptor_annotations.pr 2019-03-22 14:05:44 -04:00
task.go Fix a typo in task.go 2019-12-30 13:40:33 +08:00
unpacker.go Pass snapshotter opts during Pull 2020-03-02 13:45:40 -08:00
vendor.conf vendor: golang.org/x/sys 52ab431487773bc9dd1b0766228b1cf3944126bf 2020-03-07 14:35:36 +01:00

containerd banner

GoDoc Build Status Windows 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.

Nightly builds

There are nightly builds available for download here. Binaries are generated from master branch every night for Linux and Windows.

Please be aware: nightly builds might have critical bugs, it's not recommended for use in prodution and no support provided.

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.


import (
  "github.com/containerd/containerd"
  "github.com/containerd/containerd/cio"
)


func 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:

context = context.Background()
// create a context for docker
docker = namespaces.WithNamespace(context, "docker")

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

To set a default namespace on the client:

client, err := containerd.New(address, containerd.WithDefaultNamespace("docker"))

Distribution

// pull an image
image, err := client.Pull(context, "docker.io/library/redis:latest")

// push an image
err := 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.

redis, err := client.NewContainer(context, "redis-master")
defer 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.

redis, 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.

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

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

// use a readonly filesystem with multiple containers
for 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.

// create a new task
task, err := redis.NewTask(context, cio.Stdio)
defer task.Delete(context)

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

// start the redis-server process inside the container
err := task.Start(context)

// wait for the task to exit and get the exit status
status, 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.

// checkpoint the task then push it to a registry
checkpoint, err := task.Checkpoint(context)

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

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

redis, err = client.NewContainer(context, "redis-master", containerd.WithNewSnapshot("redis-rootfs", checkpoint))
defer container.Delete(context)

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

err := task.Start(context)

Snapshot Plugins

In addition to the built-in Snapshot plugins in containerd, additional external plugins can be configured using GRPC. An external plugin is made available using the configured name and appears as a plugin alongside the built-in ones.

To add an external snapshot plugin, add the plugin to containerd's config file (by default at /etc/containerd/config.toml). The string following proxy_plugin. will be used as the name of the snapshotter and the address should refer to a socket with a GRPC listener serving containerd's Snapshot GRPC API. Remember to restart containerd for any configuration changes to take effect.

[proxy_plugins]
  [proxy_plugins.customsnapshot]
    type = "snapshot"
    address =  "/var/run/mysnapshotter.sock"

See PLUGINS.md for how to create plugins

Releases and API Stability

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

Downloadable 64-bit Intel/AMD binaries of all official releases are available on our releases page, as well as auto-published to the cri-containerd-release storage bucket.

For other architectures and distribution support, you will find that many Linux distributions package their own containerd and provide it across several architectures, such as Canonical's Ubuntu packaging.

Enabling command auto-completion

Starting with containerd 1.4, the urfave client feature for auto-creation of bash and zsh autocompletion data is enabled. To use the autocomplete feature in a bash shell for example, source the autocomplete/ctr file in your .bashrc, or manually like:

$ source ./contrib/autocomplete/ctr

Distribution of ctr autocomplete for bash and zsh

For bash, copy the contrib/autocomplete/ctr script into /etc/bash_completion.d/ and rename it to ctr. The zsh_autocomplete file is also available and can be used similarly for zsh users.

Provide documentation to users to source this file into their shell if you don't place the autocomplete file in a location where it is automatically loaded for the user's shell environment.

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: Catch us in the #containerd and #containerd-dev channels on dockercommunity.slack.com. Click here for an invite to docker community slack.

Security audit

A third party security audit was performed by Cure53 in 4Q2018; the full report is available in our docs/ directory.

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. You may obtain a copy of the license, titled CC-BY-4.0, at http://creativecommons.org/licenses/by/4.0/.

Project details

containerd is the primary open source project within the broader containerd GitHub repository. However, all projects within the repo have common maintainership, governance, and contributing guidelines which are stored in a project repository commonly for all containerd projects.

Please find all these core project documents, including the:

information in our containerd/project repository.

Adoption

Interested to see who is using containerd? Are you using containerd in a project? Please add yourself via pull request to our ADOPTERS.md file.