Go to file
Samuel Karp 7d56b24f1a
v2 runtime: reduce permissions for bundle dir
Bundle directory permissions should be 0700 by default.  On Linux with
user namespaces enabled, the remapped root also needs access to the
bundle directory.  In this case, the bundle directory is modified to
0710 and group ownership is changed to the remapped root group.

Signed-off-by: Samuel Karp <skarp@amazon.com>
2021-09-22 16:13:09 -07:00
.empty-mod go.mod: cut circular dependency on github.com/containerd/containerd 2021-05-01 13:49:23 +02:00
.github Merge pull request #6036 from dmcgowan/add-mirror-action 2021-09-21 16:06:33 -07:00
.zuul/playbooks/containerd-build Update to Go 1.17.1 2021-09-14 09:12:00 -04:00
api Script to check if entries in go.mod files are in sync 2021-07-27 17:52:32 -04:00
archive FreeBSD: fix tar headers & the nil check on getxattr 2021-09-21 19:22:41 +03:00
cio Run go fmt with Go 1.17 2021-08-22 09:31:50 +09:00
cluster Update DEPLOY_DIR and VERSION to match installation script 2020-10-16 13:32:58 -07:00
cmd Merge pull request #5997 from ktock/deduped-ref 2021-09-21 23:44:19 +09:00
containers fix-grammar-mistake 2019-08-28 16:10:08 +08:00
content Fix content copy to not ignore unexpected EOF 2021-09-09 10:01:51 -07:00
contrib seccomp: support "clone3" (return ENOSYS unless SYS_ADMIN is granted) 2021-09-15 14:44:45 +09:00
defaults darwin: runtime support 2021-09-03 09:48:21 +09:00
design Remove outdated plugin design doc 2018-07-25 23:28:09 -07:00
diff replace uses of os/exec with golang.org/x/sys/execabs 2021-08-25 18:11:09 +02:00
docs add ip_pref CNI options for primary pod ip 2021-09-10 10:04:21 -04:00
errdefs Replace errors.Cause() with errors.Is() 2020-05-08 14:36:45 +02:00
events Move plugin context events into separate plugin 2021-08-05 22:59:20 -07: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 content.ReaderAt close 2021-05-08 12:39:09 +08:00
integration bump continuity and console version that remove pkg/errors 2021-09-21 21:56:18 +08:00
labels Add shared content label to namespaces 2021-07-28 18:49:32 +00:00
leases leases: support resource management 2019-05-29 11:00:32 +08:00
log add caller info to the testHook 2021-03-23 09:26:27 +08:00
metadata Add shared content label to namespaces 2021-07-28 18:49:32 +00:00
metrics use a const metric for build_info 2021-09-09 12:20:14 -04:00
mount replace uses of os/exec with golang.org/x/sys/execabs 2021-08-25 18:11:09 +02:00
namespaces docs: Various typo found by codespell 2020-12-22 13:22:16 +08:00
oci Merge pull request #5122 from mythi/non-root-containers-and-devices-v2 2021-08-31 16:11:18 -05:00
pkg Enable image config labels in ctr and CRI container creation 2021-09-15 15:31:19 -04:00
platforms darwin: runtime support 2021-09-03 09:48:21 +09:00
plugin Fix typo 2021-09-15 03:13:25 +00:00
protobuf/plugin Introduce a new go module - containerd/api for use in standalone clients 2021-07-27 07:34:59 -04:00
reference Handle an image ref with scheme 2020-11-19 10:58:21 -08:00
releases fixing some doc links 2021-06-21 18:24:47 -05:00
remotes Merge pull request #5921 from ktock/fix-failed-precondition 2021-08-30 14:01:19 -04:00
reports fixing some doc links 2021-06-21 18:24:47 -05:00
rootfs Run go fmt with Go 1.17 2021-08-22 09:31:50 +09:00
runtime v2 runtime: reduce permissions for bundle dir 2021-09-22 16:13:09 -07:00
script CI: bump up crun to 1.0 2021-09-15 14:45:06 +09:00
services Merge pull request #5817 from dmcgowan/shim-plugins 2021-09-12 18:18:20 +08:00
snapshots add xfs support to devicemapper snapshotter 2021-09-11 21:43:27 -07:00
sys replace uses of os/exec with golang.org/x/sys/execabs 2021-08-25 18:11:09 +02:00
test scripts: declare ROOT closer to where it's used, and some DRY changes 2021-08-03 17:27:03 +02:00
tracing [otel-tracing] Initial opentelemetry support 2021-08-04 14:25:01 -07:00
vendor bump continuity and console version that remove pkg/errors 2021-09-21 21:56:18 +08:00
version Prepare 1.5.0 release notes 2021-05-03 09:32:52 -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 script: update golangci-lint from v1.38.0 and v1.36.0 to v1.42.0 2021-08-19 16:27:16 -07:00
.mailmap Prepare 1.5.0-rc.1 release 2021-04-12 22:01:49 -07:00
.zuul.yaml add integration tests 2021-04-22 20:53:49 -04:00
ADOPTERS.md ADOPTERS.md: Add the Inclavare-Containers container runtime 2020-12-03 17:02:43 +08:00
BUILDING.md BUILDING.md: remove some bits about building runc 2021-08-10 09:31:02 +02:00
client_opts.go remotes/ctr: allow to limit max concurrent uploads like downloads 2021-03-25 14:37:02 +08:00
client.go using Hosts replace deprecated field 2021-09-05 11:52:46 +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 Run go fmt with Go 1.17 2021-08-22 09:31:50 +09:00
container_opts.go Enable image config labels in ctr and CRI container creation 2021-09-15 15:31:19 -04:00
container_restore_opts.go bug fix:#3448 2020-11-03 07:47:28 +00:00
container.go go.mod: github.com/containerd/fifo v1.0.0 2021-04-19 09:27:45 +02: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 bump continuity and console version that remove pkg/errors 2021-09-21 21:56:18 +08:00
go.sum bump continuity and console version that remove pkg/errors 2021-09-21 21:56:18 +08: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 import: Add option to skip creating digest image 2021-09-15 20:20:57 +09:00
install_opts.go Add optional install path 2018-09-11 10:36:00 -04:00
install.go Fix content.ReaderAt close 2021-05-08 12:39:09 +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 Fix bad make protos failure 2021-08-10 16:03:54 -04: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 Makefile.linux: build on riscv with PIE 2021-09-02 20:06:40 -07: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 add current process state to the error message 2021-09-21 13:29:57 -07:00
Protobuild.toml Introduce a new go module - containerd/api for use in standalone clients 2021-07-27 07:34:59 -04:00
pull.go Set content labels based on content type 2020-07-21 00:46:07 -07:00
README.md Merge pull request #5847 from kzys/master-to-main 2021-08-10 15:06:06 -07:00
RELEASES.md Update RELEASES.md 2021-08-26 14:45:14 +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 Allow WithServices to use custom implementations 2021-07-09 23:30:40 +00:00
signals.go Support SIGRTMIN+n signals 2021-07-26 09:36:43 -07:00
snapshotter_default_linux.go Licence header added 2018-02-19 10:32:26 +09:00
snapshotter_default_unix.go Run go fmt with Go 1.17 2021-08-22 09:31:50 +09:00
snapshotter_default_windows.go Licence header added 2018-02-19 10:32:26 +09:00
snapshotter_opts_unix.go Run go fmt with Go 1.17 2021-08-22 09:31:50 +09:00
task_opts_unix.go Run go fmt with Go 1.17 2021-08-22 09:31:50 +09:00
task_opts.go Fixes task kill --force on Windows 2021-09-04 13:54:46 -07:00
task.go task delete: Closes task IO before waiting 2021-09-07 02:17:01 -07: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.17.1 2021-09-14 09:12:00 -04:00

containerd banner

PkgGoDev Build Status Nightlies 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 main 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.

Supported Registries

Any registry which is compliant with the OCI Distribution Specification is supported by containerd.

For configuring registries, see registry host configuration documentation

Features

Client

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


import (
  "context"

  "github.com/containerd/containerd"
  "github.com/containerd/containerd/cio"
  "github.com/containerd/containerd/namespaces"
)


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.