Go to file
Stefan Berger 1917ca5f79 Allow passing environent variables to StreamProcessors
Add support for an 'env' field to the StreamProcessor configuration
and append the environment variables found there to the os.Environ()
array.
The env field takes environment variables in the form of key=value.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
2021-01-11 13:15:12 -05:00
.github ISSUE_TEMPLATE: remove redundant "report a security issue" button 2021-01-01 05:23:54 +09:00
.zuul/playbooks/containerd-build Bump Golang 1.15.5 2020-11-16 14:36:35 +09:00
api Add copyright header to proto files 2021-01-05 10:44:07 -08:00
archive Compile for FreeBSD 2020-12-09 00:30:29 -08:00
cio Add logging binary support when terminal is true 2020-08-25 17:28:29 -07:00
cluster Update DEPLOY_DIR and VERSION to match installation script 2020-10-16 13:32:58 -07:00
cmd export: add --skip-non-distributable 2021-01-01 06:32:01 +09:00
containers fix-grammar-mistake 2019-08-28 16:10:08 +08:00
content content: include the staleness of the lock when tryLock() fails 2020-12-02 14:08:02 -08:00
contrib docs: point cri release tarball to github release page 2021-01-03 17:50:40 +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 Allow passing environent variables to StreamProcessors 2021-01-11 13:15:12 -05:00
docs docs: point cri release tarball to github release page 2021-01-03 17:50:40 +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
fuzz Added 2 fuzzers 2020-12-19 12:59:52 +00:00
gc vendor: update gotest.tools v3.0.2 2020-02-28 17:47:20 +01:00
hack remove unused hack/utils.sh 2020-11-30 19:29:49 +09:00
identifiers Clarify requirements for identifiers validation 2019-11-04 21:22:10 -05:00
images Fix typo in comment 2021-01-06 17:01:29 +08:00
integration getting cri integration up and running 2020-10-19 10:02:05 -05: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 Allow configuration of different log formats: text, json 2020-12-04 13:12:41 -05:00
metadata fix make test failure of missing sha256 package 2020-09-10 18:50:49 +09:00
metrics cgroup2: implement containerd.events.TaskOOM event 2020-06-01 14:00:13 +09:00
mount mount: extract FUSE unmounting to a function 2020-10-01 17:29:40 +02:00
namespaces docs: Various typo found by codespell 2020-12-22 13:22:16 +08:00
oci oci: expose getUserFromPath and getGIDFromPath 2020-12-14 21:53:17 +09:00
pkg docs: Various typo found by codespell 2020-12-22 13:22:16 +08:00
platforms Refactor platforms.Only with a "platformVector" helper 2020-12-28 14:11:14 -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 v1.4.0 2020-08-16 22:56:31 -07:00
remotes docs: Various typo found by codespell 2020-12-22 13:22:16 +08:00
reports docs: Various typo found by codespell 2020-12-22 13:22:16 +08:00
rootfs Optimize Windows and LCOW snapshotters to only create scratch layer on the final snapshot 2020-11-30 16:25:38 -08:00
runtime Add copyright header to proto files 2021-01-05 10:44:07 -08:00
script/setup Change to GOPATH before go get 2020-12-01 01:39:10 +08:00
services Allow passing environent variables to StreamProcessors 2021-01-11 13:15:12 -05:00
snapshots docs: Various typo found by codespell 2020-12-22 13:22:16 +08:00
sys Add bounds on max oom_score_adj value for AdjustOOMScore 2020-12-14 15:09:24 -05:00
test docs: Various typo found by codespell 2020-12-22 13:22:16 +08:00
vendor Update hcsshim and go-winio vendoring 2020-12-18 16:56:29 -08:00
version Prepare v1.4.0 2020-08-16 22:56:31 -07:00
.gitattributes Enable linter on windows 2020-10-07 15:08:20 -07:00
.gitignore Prepare cri for merge to containerd 2020-10-07 10:58:39 -07:00
.golangci.yml Prepare cri for merge to containerd 2020-10-07 10:58:39 -07:00
.mailmap Prepare v1.4.0 2020-08-16 22:56:31 -07:00
.zuul.yaml Change nodeset to ubuntu-xenial-arm64-openlab 2020-07-30 09:22:38 +08:00
ADOPTERS.md ADOPTERS.md: Add the Inclavare-Containers container runtime 2020-12-03 17:02:43 +08:00
benchmark_test.go Add testing log context 2019-07-16 10:31:43 -07:00
BUILDING.md docs: Tweak installing btrfs dependency on Debian/Ubuntu 2020-12-22 13:22:16 +08:00
client_opts.go Set content labels based on content type 2020-07-21 00:46:07 -07:00
client_test.go add optional check that snapshotter supports the image platform when unpacking 2020-12-10 10:54:22 -08:00
client_ttrpc_test.go fix dial error when clean up a dead shim 2020-03-12 10:57:55 +08:00
client_unix_test.go Fix client tests to work on Windows. 2020-05-27 10:42:23 -07:00
client_windows_test.go Import Windows manifest into test build, rather than copying by script 2020-07-29 06:02:35 +10:00
client.go add optional check that snapshotter supports the image platform when unpacking 2020-12-10 10:54:22 -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_checkpoint_test.go Add testing log context 2019-07-16 10:31:43 -07:00
container_linux_test.go docs: Various typo found by codespell 2020-12-22 13:22:16 +08:00
container_opts_unix.go Support configurable default platform in the client. 2019-09-03 13:34:25 -07: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_test.go runtime: should not send duplicate task exit event 2020-12-01 21:54:04 +08: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
content_test.go Fix cleanup error on content client test 2019-11-26 11:22:35 -08:00
daemon_config_linux_test.go cgroup2 CI 2020-05-22 01:15:12 +09: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
go.mod Update hcsshim and go-winio vendoring 2020-12-18 16:56:29 -08:00
go.sum Update hcsshim and go-winio vendoring 2020-12-18 16:56:29 -08: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 Fix client tests to work on Windows. 2020-05-27 10:42:23 -07:00
image_store.go Copy annotations around where necessary 2019-03-06 12:26:23 -05:00
image_test.go Refactor platforms.Only with a "platformVector" helper 2020-12-28 14:11:14 -08:00
image.go add optional check that snapshotter supports the image platform when unpacking 2020-12-10 10:54:22 -08: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 Replace errors.Cause() with errors.Is() 2020-05-08 14:36:45 +02: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 docs: Various typo found by codespell 2020-12-22 13:22:16 +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 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
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 Set content labels based on content type 2020-07-21 00:46:07 -07:00
README.md docs: point cri release tarball to github release page 2021-01-03 17:50:40 +08:00
RELEASES.md Update backports documentation 2020-11-19 12:00:37 -08:00
ROADMAP.md Update roadmap.md with issue labels and milestones 2018-01-04 10:47:06 -05:00
RUNC.md docs: update RUNC.md 2020-12-15 21:42:36 +08: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_test.go ParseSignal: drop add'l check for numeric signals 2020-03-17 14:17:03 -07: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
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
snapshotter_opts_unix.go Make unique snapshotter opt for label-assisted remapping 2020-06-26 13:14:28 -04: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 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 Remove reference of GO111MODULE=off 2020-12-01 01:39:10 +08: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 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 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.