Go to file
Michael Crosby 969b3d638b
Merge pull request #5202 from wzshiming/fix/dgst-debug
Change dgst to digest in debug
2021-03-18 11:54:44 -04:00
.github Merge pull request #5178 from estesp/go-1.16.2 2021-03-12 08:23:18 -08:00
.zuul/playbooks/containerd-build Update to Go 1.16.2 2021-03-12 09:59:01 -05:00
api Update gogo/protobuf to v1.3.2 2021-01-28 12:57:50 +00:00
archive gofmt -s -w all the things 2021-03-16 21:29:41 +01:00
cio cio.copyIO: refactor to use cio.Close() (windows) 2021-02-01 11:22:08 +01:00
cluster Update DEPLOY_DIR and VERSION to match installation script 2020-10-16 13:32:58 -07:00
cmd Merge pull request #5202 from wzshiming/fix/dgst-debug 2021-03-18 11:54:44 -04:00
containers fix-grammar-mistake 2019-08-28 16:10:08 +08:00
content Fix exported comments enforcer in CI 2021-03-12 08:47:05 -08:00
contrib upgrade pause image to 3.5 for non-root 2021-03-16 23:20:35 +08: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 Merge pull request #5202 from wzshiming/fix/dgst-debug 2021-03-18 11:54:44 -04:00
docs upgrade pause image to 3.5 for non-root 2021-03-16 23:20:35 +08:00
errdefs Replace errors.Cause() with errors.Is() 2020-05-08 14:36:45 +02:00
events [events/exchange_test] Fix deadlock in TestExchangeFilters 2020-07-10 10:27:42 -04: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 Fix exported comments enforcer in CI 2021-03-12 08:47:05 -08:00
integration Merge pull request #5211 from pacoxu/pause/3.5 2021-03-18 11:43:59 -04:00
labels add Image content converter 2021-01-22 13:33:19 +09:00
leases leases: support resource management 2019-05-29 11:00:32 +08:00
log Allow configuration of different log formats: text, json 2020-12-04 13:12:41 -05:00
metadata content: support filters on local.store#Walk() 2020-11-11 11:17:48 -08:00
metrics cgroup2: implement containerd.events.TaskOOM event 2020-06-01 14:00:13 +09:00
mount Fix exported comments enforcer in CI 2021-03-12 08:47:05 -08:00
namespaces docs: Various typo found by codespell 2020-12-22 13:22:16 +08:00
oci Support adding devices by dir 2021-03-15 16:42:23 +00:00
pkg Merge pull request #5211 from pacoxu/pause/3.5 2021-03-18 11:43:59 -04:00
platforms Merge pull request #4943 from AkihiroSuda/platforms-literallyonly 2021-01-20 17:27:43 -08:00
plugin Replace errors.Cause() with errors.Is() 2020-05-08 14:36:45 +02:00
protobuf/plugin vendor protobuf & grpc 2020-02-26 10:57:05 +09:00
reference Handle an image ref with scheme 2020-11-19 10:58:21 -08:00
releases Prepare release notes for v1.5.0-beta.4 2021-03-15 16:14:27 -07:00
remotes Merge pull request #5160 from MadhavJivrajani/master 2021-03-17 09:37:17 -04:00
reports docs: Various typo found by codespell 2020-12-22 13:22:16 +08:00
rootfs rootfs: fix the error handling of the createInitLayer 2021-03-15 15:48:48 +08:00
runtime runtime/v2: add comment for checkCopyShimLogError 2021-03-18 13:02:28 +08:00
script Merge pull request #5180 from dmcgowan/lint-enforce-comments 2021-03-15 10:50:06 -04:00
services Fix exported comments enforcer in CI 2021-03-12 08:47:05 -08:00
snapshots move overlay-checks to an overlayutils package 2021-03-15 19:18:50 +01:00
sys Bring OpenBSD support 2021-01-04 14:43:48 +01:00
test Create symlink to avoid duplicate cloud init 2021-03-08 15:52:59 -05:00
vendor Merge pull request #5210 from thaJeztah/bump_k8s 2021-03-18 11:44:55 -04:00
version Prepare release notes for v1.5.0-beta.4 2021-03-15 16:14:27 -07:00
.gitattributes Enable linter on windows 2020-10-07 15:08:20 -07:00
.gitignore Add CRI release functionality to makefile 2020-09-23 14:10:27 -07:00
.golangci.yml Fix exported comments enforcer in CI 2021-03-12 08:47:05 -08:00
.mailmap Update mailmap 2021-03-15 16:14:27 -07:00
.zuul.yaml Switch from merge-resolve(default) to merge mode for containerd-build-arm64 2021-03-11 16:53:15 -05:00
ADOPTERS.md ADOPTERS.md: Add the Inclavare-Containers container runtime 2020-12-03 17:02:43 +08:00
BUILDING.md Separate runc binary version from libcontainer version 2021-03-10 13:41:12 +01:00
client_opts.go Set content labels based on content type 2020-07-21 00:46:07 -07:00
client.go Fix exported comments enforcer in CI 2021-03-12 08:47:05 -08:00
code-of-conduct.md Add code of conduct 2017-04-04 09:41:38 -07:00
codecov.yml Set codecov to not comment on PRs 2020-05-13 09:19:42 -04:00
container_checkpoint_opts.go Copy annotations around where necessary 2019-03-06 12:26:23 -05:00
container_opts_unix.go Make unique snapshotter opt for label-assisted remapping 2020-06-26 13:14:28 -04:00
container_opts.go container_opts.go: add WithAdditionalContainerLabels 2020-12-14 16:44:47 +09:00
container_restore_opts.go bug fix:#3448 2020-11-03 07:47:28 +00:00
container.go Add Spec() method to task 2020-07-27 21:32:15 -04:00
containerd.service Merge pull request #4475 from thaJeztah/minor_systemd_updates 2020-08-18 00:15:14 +08:00
containerstore.go Add containers streaming API 2018-07-26 13:55:20 -04: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.go Update image export to support Docker format 2019-04-04 15:23:06 -07:00
go.mod Merge pull request #5210 from thaJeztah/bump_k8s 2021-03-18 11:44:55 -04:00
go.sum Merge pull request #5210 from thaJeztah/bump_k8s 2021-03-18 11:44:55 -04:00
grpc.go Switch from x/net/context to context 2018-04-24 14:33:34 -07:00
image_store.go Copy annotations around where necessary 2019-03-06 12:26:23 -05:00
image.go add optional check that snapshotter supports the image platform when unpacking 2020-12-10 10:54:22 -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.go WithLease: always return context and done fn 2020-04-25 21:16:43 -07:00
LICENSE Edit Containerd license info so GitHub recognizes it 2018-04-02 12:31:15 -07:00
Makefile Separate go module for client tests 2021-03-11 19:27:45 -05: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 riscv64 arch does not support -buildmode=pie 2020-05-20 16:28:10 -03: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
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 Set content labels based on content type 2020-07-21 00:46:07 -07:00
README.md Separate runc binary version from libcontainer version 2021-03-10 13:41:12 +01:00
RELEASES.md Update RELEASES.md to reflect latest releases 2021-03-04 22:10:24 -08:00
ROADMAP.md Update roadmap.md with issue labels and milestones 2018-01-04 10:47:06 -05:00
SCOPE.md Update usage of whitelist in project 2020-06-08 12:49:22 -05:00
services.go create local version of introspection service 2020-01-02 12:34:23 -08:00
signals_unix.go ParseSignal: drop add'l check for numeric signals 2020-03-17 14:17:03 -07: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
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
snapshotter_opts_unix.go Make unique snapshotter opt for label-assisted remapping 2020-06-26 13:14:28 -04:00
task_opts_unix.go support user remapping in ctr 2019-12-12 01:16:47 -06:00
task_opts.go Add annotations to task update request api 2020-11-09 14:13:33 -08:00
task.go Add annotations to task update request api 2020-11-09 14:13:33 -08:00
unpacker.go add optional check that snapshotter supports the image platform when unpacking 2020-12-10 10:54:22 -08:00
Vagrantfile Update to Go 1.16.2 2021-03-12 09:59:01 -05:00

containerd banner

PkgGoDev Build Status Nightlies 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 a member of CNCF with 'graduated' status.

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

architecture

Now Recruiting

We are a large inclusive OSS project that is welcoming help of any kind shape or form:

  • Documentation help is needed to make the product easier to consume and extend.
  • We need OSS community outreach / organizing help to get the word out; manage and create messaging and educational content; and to help with social media, community forums/groups, and google groups.
  • We are actively inviting new security advisors to join the team.
  • New sub-projects are being created, core and non-core that could use additional development help.
  • Each of the containerd projects has a list of issues currently being worked on or that need help resolving.
    • If the issue has not already been assigned to someone, or has not made recent progress and you are interested, please inquire.
    • If you are interested in starting with a smaller / beginner level issue, look for issues with an exp/beginner tag, for example containerd/containerd beginner issues.

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 production 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 described 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 built in 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.NewCreator(cio.WithStdio))
defer task.Delete(context)

// the task is now running and has a pid that can be used 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 allows 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.NewCreator(cio.WithStdio), 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.

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.

CRI

cri is a containerd plugin implementation of the Kubernetes container runtime interface (CRI). With it, you are able to use containerd as the container runtime for a Kubernetes cluster.

cri

CRI Status

cri is a native plugin of containerd. Since containerd 1.1, the cri plugin is built into the release binaries and enabled by default.

Note: As of containerd 1.5, the cri plugin is merged into the containerd/containerd repo. For example, the source code previously stored under containerd/cri/pkg was moved to containerd/containerd/pkg/cri package.

The cri plugin has reached GA status, representing that it is:

See results on the containerd k8s test dashboard

Validating Your cri Setup

A Kubernetes incubator project, cri-tools, includes programs for exercising CRI implementations. More importantly, cri-tools includes the program critest which is used for running CRI Validation Testing.

CRI Guides

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 catch us in the #containerd and #containerd-dev slack channels on Cloud Native Computing Foundation's (CNCF) slack - cloud-native.slack.com. Everyone is welcome to join and chat. Get Invite to CNCF 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.