File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ import (
2626 "github.com/containerd/containerd"
2727 "github.com/containerd/containerd/cio"
2828 "github.com/containerd/containerd/cmd/ctr/commands"
29+ "github.com/containerd/containerd/oci"
2930 "github.com/sirupsen/logrus"
3031 "github.com/urfave/cli"
3132)
@@ -61,6 +62,10 @@ var execCommand = cli.Command{
6162 Name : "log-uri" ,
6263 Usage : "log uri for custom shim logging" ,
6364 },
65+ cli.StringFlag {
66+ Name : "user" ,
67+ Usage : "user id or name" ,
68+ },
6469 },
6570 Action : func (context * cli.Context ) error {
6671 var (
@@ -85,15 +90,25 @@ var execCommand = cli.Command{
8590 if err != nil {
8691 return err
8792 }
88- task , err := container .Task (ctx , nil )
89- if err != nil {
90- return err
93+ if user := context .String ("user" ); user != "" {
94+ c , err := container .Info (ctx )
95+ if err != nil {
96+ return err
97+ }
98+ if err := oci .WithUser (user )(ctx , client , & c , spec ); err != nil {
99+ return err
100+ }
91101 }
92102
93103 pspec := spec .Process
94104 pspec .Terminal = tty
95105 pspec .Args = args
96106
107+ task , err := container .Task (ctx , nil )
108+ if err != nil {
109+ return err
110+ }
111+
97112 var (
98113 ioCreator cio.Creator
99114 stdinC = & stdinCloser {
You can’t perform that action at this time.
0 commit comments