From 1167035be358795551d61c097565f4b7c6a4434e Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Thu, 11 Jan 2018 14:04:11 +0900 Subject: [PATCH] ctr: promote cOpts over opts, as oci.WithImageConfig requires snapshot Signed-off-by: Akihiro Suda --- cmd/ctr/commands/run/run_unix.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/ctr/commands/run/run_unix.go b/cmd/ctr/commands/run/run_unix.go index bf25092a2..45137f884 100644 --- a/cmd/ctr/commands/run/run_unix.go +++ b/cmd/ctr/commands/run/run_unix.go @@ -75,7 +75,10 @@ func newContainer(ctx gocontext.Context, client *containerd.Client, context *cli if context.Bool("net-host") { opts = append(opts, oci.WithHostNamespace(specs.NetworkNamespace), oci.WithHostHostsFile, oci.WithHostResolvconf) } - cOpts = append([]containerd.NewContainerOpts{containerd.WithNewSpec(opts...)}, cOpts...) + // oci.WithImageConfig (WithUsername, WithUserID) depends on rootfs snapshot for resolving /etc/passwd. + // So cOpts needs to have precedence over opts. + // TODO: WithUsername, WithUserID should additionally support non-snapshot rootfs + cOpts = append(cOpts, []containerd.NewContainerOpts{containerd.WithNewSpec(opts...)}...) return client.NewContainer(ctx, id, cOpts...) }