Skip to content

Commit 51590f2

Browse files
committed
ctr: promote cOpts over opts, as oci.WithImageConfig requires snapshot
Signed-off-by: Akihiro Suda <[email protected]>
1 parent 0a2c2a2 commit 51590f2

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

cmd/ctr/commands/run/run_unix.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ func newContainer(ctx gocontext.Context, client *containerd.Client, context *cli
7272
if context.Bool("net-host") {
7373
opts = append(opts, oci.WithHostNamespace(specs.NetworkNamespace), oci.WithHostHostsFile, oci.WithHostResolvconf)
7474
}
75-
cOpts = append([]containerd.NewContainerOpts{containerd.WithNewSpec(opts...)}, cOpts...)
75+
// oci.WithImageConfig (WithUsername, WithUserID) depends on rootfs snapshot for resolving /etc/passwd.
76+
// So cOpts needs to have precedence over opts.
77+
// TODO: WithUsername, WithUserID should additionally support non-snapshot rootfs
78+
cOpts = append(cOpts, []containerd.NewContainerOpts{containerd.WithNewSpec(opts...)}...)
7679
return client.NewContainer(ctx, id, cOpts...)
7780
}

0 commit comments

Comments
 (0)