Go to file
Kohei Tokunaga 4ccb7aa221 Enable to propagate necessary information to snapshotter during unpack
Though containerd gives ChainID to backend snapshotters during unpack for
searching snapshots to be skipped downloading the contents, ChainID isn't enough
for some snapshotters which require additional information of layers.
Some examples are remote snapshotters which is based on stargz filesystem
(requires image-related information to query the contents to docker registry)
and those which is based on CernVM-FS (requires manifest digest, etc. for
providing squashed rootfs).

This commit solves this issue by enabling a handler to inject additional
information of layers to snapshotters during unpack.

Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
2019-12-23 10:39:40 +09:00
.github Cross build nightly builds (arm64, s390x, ppc64el) 2019-11-14 15:29:56 -08:00
.zuul/playbooks/containerd-build Add OpenLab CI configuration 2019-05-08 17:21:41 +08:00
api Added filters to snapshots API 2019-10-24 11:11:22 -07:00
archive archive: truncate modification time 2019-08-27 17:42:32 -07:00
cio Fix potential panic for task in unknown state. 2019-09-02 00:38:06 -07:00
cmd cpu metrics consistency 2019-12-17 12:30:12 +02:00
containers fix-grammar-mistake 2019-08-28 16:10:08 +08:00
content Crypto library movement and changes to content helper interfaces 2019-07-17 15:21:29 -04:00
contrib Merge pull request #3815 from estesp/fix-Dockerfile 2019-11-11 14:12:27 +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 apply: use naive applier when running in UserNS 2019-10-24 13:33:09 +09:00
docs windows process shim installer 2019-10-30 16:22:02 -07: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 fix: linter issue 2019-01-23 22:54:51 +08:00
gc Add flat GC label for leases 2019-07-18 11:16:46 -07:00
identifiers Clarify requirements for identifiers validation 2019-11-04 21:22:10 -05:00
images Return not found error if no platform matched. 2019-10-28 22:37:07 -07: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 Use logrus trace support. 2019-10-24 20:12:19 -07:00
metadata Support target snapshot references on prepare 2019-11-25 10:07:25 -08:00
metrics make cpu metrics consistent with v2 docs 2019-12-17 12:22:55 +02:00
mount Update continuity vendor 2019-08-16 15:49:47 -07:00
namespaces Use common identifiers package with less restrictive regex 2019-11-04 21:22:01 -05:00
oci Split uid and gid user ns remapping in oci 2019-12-10 03:07:50 -06:00
pkg Fix container pid. 2019-12-02 01:02:22 -08:00
platforms update cpuinfo to make variant matches aarch64 and so on 2019-11-30 23:48:10 +08:00
plugin Allow explicit configuration of TTRPC address 2019-08-22 00:56:27 -07:00
protobuf/plugin Regenerate protobufs 2019-04-03 23:41:15 +02:00
reference Fix panic on reference.Spec.Hostname() 2019-11-11 13:53:31 +08:00
releases Update release docs for 1.3.0 2019-09-26 17:00:26 -07:00
remotes Improve host fallback behaviour in docker remote 2019-12-13 11:42:32 +11:00
reports Perfect documentation 2019-09-25 16:59:31 +08:00
rootfs rootfs: use new ctx to cleanup instead of canceled one 2019-08-27 11:27:34 +08:00
runtime runtime v2: Close platform in runc shim's Shutdown method. 2019-12-19 09:47:40 -05:00
script Update after review comments 2019-12-13 08:07:23 +01:00
services support cgroup2 2019-12-12 02:56:51 +09:00
snapshots Attempt to make device mapper snapshotter tests less flaky 2019-12-13 13:20:23 -08:00
sys sys: mkdirAs: do chown if dir already exists 2019-12-18 14:19:19 +09:00
vendor Update containerd/console vendor for fix 2019-12-20 11:33:11 -05:00
version version: use runtime.Version() directly 2019-10-07 22:45:26 +08:00
.appveyor.yml Make sure for next release branch appveyor runs 2019-12-03 12:51:12 -05: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 to reduce duplicates 2019-11-08 11:41:54 -08:00
.travis.yml Disable criu tests in Travis CI 2019-12-19 00:06:12 -05: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 Correct grammar/typo in BUILDING.MD 2019-12-10 12:19:51 +01:00
client_opts.go Add client unpack opts 2019-11-13 20:32:55 -05:00
client_test.go Move flag.Parse in tests to TestMain 2019-10-11 13:27:54 -04:00
client_ttrpc_test.go Move ttrpc client to pkg/ttrpcutil 2019-05-20 16:44:49 -07: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 Support configurable default platform in the client. 2019-09-03 13:34:25 -07: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 Fix potential panic for task in unknown state. 2019-09-02 00:38:06 -07:00
containerd.service Add local-fs.target to service file 2019-10-10 17:06:39 -04: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 test: Do SynchronousDelete cleanup before testing ImageIsUnpacked 2019-11-17 11:01:35 +08:00
image.go Return the underlying images metadata 2019-12-04 13:03:41 -05:00
import_test.go Merge pull request #3135 from dmcgowan/archive-importer-docker-types 2019-07-17 09:25:40 -04: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 windows process shim installer 2019-10-30 16:22:02 -07: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 Disable criu tests in Travis CI 2019-12-19 00:06:12 -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 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 Enable to propagate necessary information to snapshotter during unpack 2019-12-23 10:39:40 +09:00
README.md Update README 2019-11-14 15:48:02 -08:00
RELEASES.md RELEASES.md: 1.1 EOL 2019-10-24 19:38:49 +09: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 Add leases manager interface 2018-07-18 10:43:37 -07: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 Merge pull request #3000 from stefanberger/descriptor_annotations.pr 2019-03-22 14:05:44 -04:00
unpacker.go Enable to propagate necessary information to snapshotter during unpack 2019-12-23 10:39:40 +09:00
vendor.conf Update containerd/console vendor for fix 2019-12-20 11:33:11 -05: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.