diff options
| author | Brian Goff <cpuguy83@gmail.com> | 2020-07-07 13:33:46 -0700 |
|---|---|---|
| committer | Brian Goff <cpuguy83@gmail.com> | 2020-07-13 14:18:02 -0700 |
| commit | f63f73a4a8f531813d6b46a2347cab4bfd210df7 (patch) | |
| tree | 7723cae5a0560466972f3c45d3a10d109a2b18e6 /plugin/executor | |
| parent | 6fd94aa933f774dc6f582a96f800b1e875628be3 (diff) | |
| download | docker-f63f73a4a8f531813d6b46a2347cab4bfd210df7.tar.gz | |
Configure shims from runtime config
In dockerd we already have a concept of a "runtime", which specifies the
OCI runtime to use (e.g. runc).
This PR extends that config to add containerd shim configuration.
This option is only exposed within the daemon itself (cannot be
configured in daemon.json).
This is due to issues in supporting unknown shims which will require
more design work.
What this change allows us to do is keep all the runtime config in one
place.
So the default "runc" runtime will just have it's already existing shim
config codified within the runtime config alone.
I've also added 2 more "stock" runtimes which are basically runc+shimv1
and runc+shimv2.
These new runtime configurations are:
- io.containerd.runtime.v1.linux - runc + v1 shim using the V1 shim API
- io.containerd.runc.v2 - runc + shim v2
These names coincide with the actual names of the containerd shims.
This allows the user to essentially control what shim is going to be
used by either specifying these as a `--runtime` on container create or
by setting `--default-runtime` on the daemon.
For custom/user-specified runtimes, the default shim config (currently
shim v1) is used.
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Diffstat (limited to 'plugin/executor')
| -rw-r--r-- | plugin/executor/containerd/containerd.go | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/plugin/executor/containerd/containerd.go b/plugin/executor/containerd/containerd.go index aeeb2184ec..8354745990 100644 --- a/plugin/executor/containerd/containerd.go +++ b/plugin/executor/containerd/containerd.go @@ -3,12 +3,11 @@ package containerd // import "github.com/docker/docker/plugin/executor/container import ( "context" "io" - "path/filepath" "sync" "github.com/containerd/containerd" "github.com/containerd/containerd/cio" - "github.com/containerd/containerd/runtime/linux/runctypes" + "github.com/docker/docker/api/types" "github.com/docker/docker/errdefs" "github.com/docker/docker/libcontainerd" libcontainerdtypes "github.com/docker/docker/libcontainerd/types" @@ -26,13 +25,14 @@ type ExitHandler interface { } // New creates a new containerd plugin executor -func New(ctx context.Context, rootDir string, cli *containerd.Client, ns string, exitHandler ExitHandler, useShimV2 bool) (*Executor, error) { +func New(ctx context.Context, rootDir string, cli *containerd.Client, ns string, exitHandler ExitHandler, runtime types.Runtime) (*Executor, error) { e := &Executor{ rootDir: rootDir, exitHandler: exitHandler, + runtime: runtime, } - client, err := libcontainerd.NewClient(ctx, cli, rootDir, ns, e, useShimV2) + client, err := libcontainerd.NewClient(ctx, cli, rootDir, ns, e) if err != nil { return nil, errors.Wrap(err, "error creating containerd exec client") } @@ -45,6 +45,7 @@ type Executor struct { rootDir string client libcontainerdtypes.Client exitHandler ExitHandler + runtime types.Runtime } // deleteTaskAndContainer deletes plugin task and then plugin container from containerd @@ -66,11 +67,8 @@ func deleteTaskAndContainer(ctx context.Context, cli libcontainerdtypes.Client, // Create creates a new container func (e *Executor) Create(id string, spec specs.Spec, stdout, stderr io.WriteCloser) error { - opts := runctypes.RuncOptions{ - RuntimeRoot: filepath.Join(e.rootDir, "runtime-root"), - } ctx := context.Background() - err := e.client.Create(ctx, id, &spec, &opts) + err := e.client.Create(ctx, id, &spec, e.runtime.Shim.Binary, e.runtime.Shim.Opts) if err != nil { status, err2 := e.client.Status(ctx, id) if err2 != nil { @@ -82,7 +80,7 @@ func (e *Executor) Create(id string, spec specs.Spec, stdout, stderr io.WriteClo if err2 := e.client.Delete(ctx, id); err2 != nil && !errdefs.IsNotFound(err2) { logrus.WithError(err2).WithField("plugin", id).Error("Error cleaning up containerd container") } - err = e.client.Create(ctx, id, &spec, &opts) + err = e.client.Create(ctx, id, &spec, e.runtime.Shim.Binary, e.runtime.Shim.Opts) } } |
