ctr/tasks: support remapped UID/GID
Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
This commit is contained in:
@@ -79,6 +79,20 @@ func NewTask(ctx gocontext.Context, client *containerd.Client, container contain
|
||||
}
|
||||
opts = append(opts, containerd.WithTaskCheckpoint(im))
|
||||
}
|
||||
|
||||
spec, err := container.Spec(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if spec.Linux != nil {
|
||||
if len(spec.Linux.UIDMappings) != 0 {
|
||||
opts = append(opts, containerd.WithUIDOwner(spec.Linux.UIDMappings[0].HostID))
|
||||
}
|
||||
if len(spec.Linux.GIDMappings) != 0 {
|
||||
opts = append(opts, containerd.WithGIDOwner(spec.Linux.GIDMappings[0].HostID))
|
||||
}
|
||||
}
|
||||
|
||||
var ioCreator cio.Creator
|
||||
if con != nil {
|
||||
if nullIO {
|
||||
@@ -106,7 +120,8 @@ func NewTask(ctx gocontext.Context, client *containerd.Client, container contain
|
||||
return t, nil
|
||||
}
|
||||
|
||||
func getNewTaskOpts(context *cli.Context) []containerd.NewTaskOpts {
|
||||
// GetNewTaskOpts resolves containerd.NewTaskOpts from cli.Context
|
||||
func GetNewTaskOpts(context *cli.Context) []containerd.NewTaskOpts {
|
||||
if context.Bool("no-pivot") {
|
||||
return []containerd.NewTaskOpts{containerd.WithNoPivotRoot}
|
||||
}
|
||||
|
Reference in New Issue
Block a user