Add support for runtime containerd namespace configuration

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
Justin Cormack 2018-01-17 14:32:51 +00:00
parent 99fd71dc7f
commit 4b9ffadb2e
2 changed files with 6 additions and 0 deletions

View File

@ -23,6 +23,7 @@ type Runtime struct {
Mkdir []string `yaml:"mkdir" json:"mkdir,omitempty"`
Interfaces []Interface `yaml:"interfaces" json:"interfaces,omitempty"`
BindNS Namespaces `yaml:"bindNS" json:"bindNS,omitempty"`
Namespace string `yaml:"namespace,omitempty" json:"namespace,omitempty"`
}
// Namespaces is the type for configuring paths to bind namespaces

View File

@ -11,6 +11,7 @@ import (
"github.com/containerd/containerd"
"github.com/containerd/containerd/cio"
"github.com/containerd/containerd/namespaces"
specs "github.com/opencontainers/runtime-spec/specs-go"
log "github.com/sirupsen/logrus"
)
@ -113,6 +114,10 @@ func start(ctx context.Context, service, sock, basePath, dumpSpec string) (strin
}
if runtimeConfig.Namespace != "" {
ctx = namespaces.WithNamespace(ctx, runtimeConfig.Namespace)
}
ctr, err := client.NewContainer(ctx, service, containerd.WithSpec(spec))
if err != nil {
return "", 0, "failed to create container", err