Windows: Experimental: Allow containerd for runtime
Signed-off-by: John Howard <jhoward@microsoft.com>
This is the first step in refactoring moby (dockerd) to use containerd on Windows.
Similar to the current model in Linux, this adds the option to enable it for runtime.
It does not switch the graphdriver to containerd snapshotters.
- Refactors libcontainerd to a series of subpackages so that either a
"local" containerd (1) or a "remote" (2) containerd can be loaded as opposed
to conditional compile as "local" for Windows and "remote" for Linux.
- Updates libcontainerd such that Windows has an option to allow the use of a
"remote" containerd. Here, it communicates over a named pipe using GRPC.
This is currently guarded behind the experimental flag, an environment variable,
and the providing of a pipename to connect to containerd.
- Infrastructure pieces such as under pkg/system to have helper functions for
determining whether containerd is being used.
(1) "local" containerd is what the daemon on Windows has used since inception.
It's not really containerd at all - it's simply local invocation of HCS APIs
directly in-process from the daemon through the Microsoft/hcsshim library.
(2) "remote" containerd is what docker on Linux uses for it's runtime. It means
that there is a separate containerd service running, and docker communicates over
GRPC to it.
To try this out, you will need to start with something like the following:
Window 1:
containerd --log-level debug
Window 2:
$env:DOCKER_WINDOWS_CONTAINERD=1
dockerd --experimental -D --containerd \\.\pipe\containerd-containerd
You will need the following binary from github.com/containerd/containerd in your path:
- containerd.exe
You will need the following binaries from github.com/Microsoft/hcsshim in your path:
- runhcs.exe
- containerd-shim-runhcs-v1.exe
For LCOW, it will require and initrd.img and kernel in `C:\Program Files\Linux Containers`.
This is no different to the current requirements. However, you may need updated binaries,
particularly initrd.img built from Microsoft/opengcs as (at the time of writing), Linuxkit
binaries are somewhat out of date.
Note that containerd and hcsshim for HCS v2 APIs do not yet support all the required
functionality needed for docker. This will come in time - this is a baby (although large)
step to migrating Docker on Windows to containerd.
Note that the HCS v2 APIs are only called on RS5+ builds. RS1..RS4 will still use
HCS v1 APIs as the v2 APIs were not fully developed enough on these builds to be usable.
This abstraction is done in HCSShim. (Referring specifically to runtime)
Note the LCOW graphdriver still uses HCS v1 APIs regardless.
Note also that this does not migrate docker to use containerd snapshotters
rather than graphdrivers. This needs to be done in conjunction with Linux also
doing the same switch.
2019-01-08 22:30:52 +00:00
|
|
|
package types // import "github.com/docker/docker/libcontainerd/types"
|
2016-03-18 18:50:19 +00:00
|
|
|
|
2016-07-15 21:12:07 +00:00
|
|
|
import (
|
2017-09-22 13:52:41 +00:00
|
|
|
"context"
|
|
|
|
"time"
|
2016-07-15 21:12:07 +00:00
|
|
|
|
2017-09-22 13:52:41 +00:00
|
|
|
"github.com/containerd/containerd"
|
2017-11-30 00:15:20 +00:00
|
|
|
"github.com/containerd/containerd/cio"
|
2016-09-27 17:26:59 +00:00
|
|
|
"github.com/opencontainers/runtime-spec/specs-go"
|
2016-07-15 21:12:07 +00:00
|
|
|
)
|
2016-03-18 18:50:19 +00:00
|
|
|
|
2017-09-22 13:52:41 +00:00
|
|
|
// EventType represents a possible event from libcontainerd
|
|
|
|
type EventType string
|
|
|
|
|
|
|
|
// Event constants used when reporting events
|
|
|
|
const (
|
|
|
|
EventUnknown EventType = "unknown"
|
|
|
|
EventExit EventType = "exit"
|
|
|
|
EventOOM EventType = "oom"
|
|
|
|
EventCreate EventType = "create"
|
|
|
|
EventStart EventType = "start"
|
|
|
|
EventExecAdded EventType = "exec-added"
|
|
|
|
EventExecStarted EventType = "exec-started"
|
|
|
|
EventPaused EventType = "paused"
|
|
|
|
EventResumed EventType = "resumed"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Status represents the current status of a container
|
|
|
|
type Status string
|
|
|
|
|
|
|
|
// Possible container statuses
|
2016-03-18 18:50:19 +00:00
|
|
|
const (
|
2017-09-22 13:52:41 +00:00
|
|
|
// Running indicates the process is currently executing
|
|
|
|
StatusRunning Status = "running"
|
|
|
|
// Created indicates the process has been created within containerd but the
|
|
|
|
// user's defined process has not started
|
|
|
|
StatusCreated Status = "created"
|
|
|
|
// Stopped indicates that the process has ran and exited
|
|
|
|
StatusStopped Status = "stopped"
|
|
|
|
// Paused indicates that the process is currently paused
|
|
|
|
StatusPaused Status = "paused"
|
|
|
|
// Pausing indicates that the process is currently switching from a
|
|
|
|
// running state into a paused state
|
|
|
|
StatusPausing Status = "pausing"
|
|
|
|
// Unknown indicates that we could not determine the status from the runtime
|
|
|
|
StatusUnknown Status = "unknown"
|
2016-03-18 18:50:19 +00:00
|
|
|
)
|
|
|
|
|
2017-09-22 13:52:41 +00:00
|
|
|
// EventInfo contains the event info
|
|
|
|
type EventInfo struct {
|
|
|
|
ContainerID string
|
|
|
|
ProcessID string
|
|
|
|
Pid uint32
|
|
|
|
ExitCode uint32
|
|
|
|
ExitedAt time.Time
|
|
|
|
OOMKilled bool
|
2018-02-09 18:08:47 +00:00
|
|
|
Error error
|
2016-03-18 18:50:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Backend defines callbacks that the client of the library needs to implement.
|
|
|
|
type Backend interface {
|
2017-09-22 13:52:41 +00:00
|
|
|
ProcessEvent(containerID string, event EventType, ei EventInfo) error
|
2016-03-18 18:50:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Client provides access to containerd features.
|
|
|
|
type Client interface {
|
2017-11-03 00:21:18 +00:00
|
|
|
Version(ctx context.Context) (containerd.Version, error)
|
|
|
|
|
2017-09-22 13:52:41 +00:00
|
|
|
Restore(ctx context.Context, containerID string, attachStdio StdioCallback) (alive bool, pid int, err error)
|
|
|
|
|
|
|
|
Create(ctx context.Context, containerID string, spec *specs.Spec, runtimeOptions interface{}) error
|
|
|
|
Start(ctx context.Context, containerID, checkpointDir string, withStdin bool, attachStdio StdioCallback) (pid int, err error)
|
|
|
|
SignalProcess(ctx context.Context, containerID, processID string, signal int) error
|
|
|
|
Exec(ctx context.Context, containerID, processID string, spec *specs.Process, withStdin bool, attachStdio StdioCallback) (int, error)
|
|
|
|
ResizeTerminal(ctx context.Context, containerID, processID string, width, height int) error
|
|
|
|
CloseStdin(ctx context.Context, containerID, processID string) error
|
|
|
|
Pause(ctx context.Context, containerID string) error
|
|
|
|
Resume(ctx context.Context, containerID string) error
|
|
|
|
Stats(ctx context.Context, containerID string) (*Stats, error)
|
|
|
|
ListPids(ctx context.Context, containerID string) ([]uint32, error)
|
|
|
|
Summary(ctx context.Context, containerID string) ([]Summary, error)
|
|
|
|
DeleteTask(ctx context.Context, containerID string) (uint32, time.Time, error)
|
|
|
|
Delete(ctx context.Context, containerID string) error
|
|
|
|
Status(ctx context.Context, containerID string) (Status, error)
|
2016-03-18 18:50:19 +00:00
|
|
|
|
2017-09-22 13:52:41 +00:00
|
|
|
UpdateResources(ctx context.Context, containerID string, resources *Resources) error
|
|
|
|
CreateCheckpoint(ctx context.Context, containerID, checkpointDir string, exit bool) error
|
2016-03-18 18:50:19 +00:00
|
|
|
}
|
|
|
|
|
2016-10-17 21:39:52 +00:00
|
|
|
// StdioCallback is called to connect a container or process stdio.
|
2017-12-07 19:26:27 +00:00
|
|
|
type StdioCallback func(io *cio.DirectIO) (cio.IO, error)
|
Windows: Experimental: Allow containerd for runtime
Signed-off-by: John Howard <jhoward@microsoft.com>
This is the first step in refactoring moby (dockerd) to use containerd on Windows.
Similar to the current model in Linux, this adds the option to enable it for runtime.
It does not switch the graphdriver to containerd snapshotters.
- Refactors libcontainerd to a series of subpackages so that either a
"local" containerd (1) or a "remote" (2) containerd can be loaded as opposed
to conditional compile as "local" for Windows and "remote" for Linux.
- Updates libcontainerd such that Windows has an option to allow the use of a
"remote" containerd. Here, it communicates over a named pipe using GRPC.
This is currently guarded behind the experimental flag, an environment variable,
and the providing of a pipename to connect to containerd.
- Infrastructure pieces such as under pkg/system to have helper functions for
determining whether containerd is being used.
(1) "local" containerd is what the daemon on Windows has used since inception.
It's not really containerd at all - it's simply local invocation of HCS APIs
directly in-process from the daemon through the Microsoft/hcsshim library.
(2) "remote" containerd is what docker on Linux uses for it's runtime. It means
that there is a separate containerd service running, and docker communicates over
GRPC to it.
To try this out, you will need to start with something like the following:
Window 1:
containerd --log-level debug
Window 2:
$env:DOCKER_WINDOWS_CONTAINERD=1
dockerd --experimental -D --containerd \\.\pipe\containerd-containerd
You will need the following binary from github.com/containerd/containerd in your path:
- containerd.exe
You will need the following binaries from github.com/Microsoft/hcsshim in your path:
- runhcs.exe
- containerd-shim-runhcs-v1.exe
For LCOW, it will require and initrd.img and kernel in `C:\Program Files\Linux Containers`.
This is no different to the current requirements. However, you may need updated binaries,
particularly initrd.img built from Microsoft/opengcs as (at the time of writing), Linuxkit
binaries are somewhat out of date.
Note that containerd and hcsshim for HCS v2 APIs do not yet support all the required
functionality needed for docker. This will come in time - this is a baby (although large)
step to migrating Docker on Windows to containerd.
Note that the HCS v2 APIs are only called on RS5+ builds. RS1..RS4 will still use
HCS v1 APIs as the v2 APIs were not fully developed enough on these builds to be usable.
This abstraction is done in HCSShim. (Referring specifically to runtime)
Note the LCOW graphdriver still uses HCS v1 APIs regardless.
Note also that this does not migrate docker to use containerd snapshotters
rather than graphdrivers. This needs to be done in conjunction with Linux also
doing the same switch.
2019-01-08 22:30:52 +00:00
|
|
|
|
|
|
|
// InitProcessName is the name given to the first process of a container
|
|
|
|
const InitProcessName = "init"
|