|
@@ -731,9 +731,9 @@ func WithCommonOptions(daemon *Daemon, c *container.Container) coci.SpecOpts {
|
|
|
Path: c.BaseFS,
|
|
|
Readonly: c.HostConfig.ReadonlyRootfs,
|
|
|
}
|
|
|
- }
|
|
|
- if err := c.SetupWorkingDirectory(daemon.idMapping.RootPair()); err != nil {
|
|
|
- return err
|
|
|
+ if err := c.SetupWorkingDirectory(daemon.idMapping.RootPair()); err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
}
|
|
|
cwd := c.Config.WorkingDir
|
|
|
if len(cwd) == 0 {
|
|
@@ -1017,7 +1017,6 @@ func (daemon *Daemon) createSpec(ctx context.Context, c *container.Container) (r
|
|
|
WithResources(c),
|
|
|
WithSysctls(c),
|
|
|
WithDevices(daemon, c),
|
|
|
- WithUser(c),
|
|
|
WithRlimits(daemon, c),
|
|
|
WithNamespaces(daemon, c),
|
|
|
WithCapabilities(c),
|
|
@@ -1028,6 +1027,20 @@ func (daemon *Daemon) createSpec(ctx context.Context, c *container.Container) (r
|
|
|
WithSelinux(c),
|
|
|
WithOOMScore(&c.HostConfig.OomScoreAdj),
|
|
|
)
|
|
|
+ if daemon.UsesSnapshotter() {
|
|
|
+ s.Root = &specs.Root{
|
|
|
+ Path: "rootfs",
|
|
|
+ }
|
|
|
+ if c.Config.User != "" {
|
|
|
+ opts = append(opts, coci.WithUser(c.Config.User))
|
|
|
+ }
|
|
|
+ if c.Config.WorkingDir != "" {
|
|
|
+ opts = append(opts, coci.WithProcessCwd(c.Config.WorkingDir))
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ opts = append(opts, WithUser(c))
|
|
|
+ }
|
|
|
+
|
|
|
if c.NoNewPrivileges {
|
|
|
opts = append(opts, coci.WithNoNewPrivileges)
|
|
|
}
|
|
@@ -1051,7 +1064,7 @@ func (daemon *Daemon) createSpec(ctx context.Context, c *container.Container) (r
|
|
|
snapshotKey = c.ID
|
|
|
}
|
|
|
|
|
|
- return &s, coci.ApplyOpts(ctx, nil, &containers.Container{
|
|
|
+ return &s, coci.ApplyOpts(ctx, daemon.containerdCli, &containers.Container{
|
|
|
ID: c.ID,
|
|
|
Snapshotter: snapshotter,
|
|
|
SnapshotKey: snapshotKey,
|