ctr: support --user for run/create
Signed-off-by: Ye Sijun <junnplus@gmail.com>
This commit is contained in:
parent
681aaf68b7
commit
f77d45e3ba
@ -205,6 +205,10 @@ var (
|
|||||||
Name: "hostname",
|
Name: "hostname",
|
||||||
Usage: "set the container's host name",
|
Usage: "set the container's host name",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "user,u",
|
||||||
|
Usage: "username or user id, group optional (format: <name|uid>[:<group|gid>])",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -196,6 +196,9 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
|
|||||||
if cwd := context.String("cwd"); cwd != "" {
|
if cwd := context.String("cwd"); cwd != "" {
|
||||||
opts = append(opts, oci.WithProcessCwd(cwd))
|
opts = append(opts, oci.WithProcessCwd(cwd))
|
||||||
}
|
}
|
||||||
|
if user := context.String("user"); user != "" {
|
||||||
|
opts = append(opts, oci.WithUser(user), oci.WithAdditionalGIDs(user))
|
||||||
|
}
|
||||||
if context.Bool("tty") {
|
if context.Bool("tty") {
|
||||||
opts = append(opts, oci.WithTTY)
|
opts = append(opts, oci.WithTTY)
|
||||||
}
|
}
|
||||||
|
@ -38,10 +38,6 @@ var platformRunFlags = []cli.Flag{
|
|||||||
Name: "isolated",
|
Name: "isolated",
|
||||||
Usage: "run the container with vm isolation",
|
Usage: "run the container with vm isolation",
|
||||||
},
|
},
|
||||||
cli.StringFlag{
|
|
||||||
Name: "user",
|
|
||||||
Usage: "run the container as the specified user",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewContainer creates a new container
|
// NewContainer creates a new container
|
||||||
@ -114,7 +110,7 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
|
|||||||
opts = append(opts, oci.WithProcessCwd(cwd))
|
opts = append(opts, oci.WithProcessCwd(cwd))
|
||||||
}
|
}
|
||||||
if user := context.String("user"); user != "" {
|
if user := context.String("user"); user != "" {
|
||||||
opts = append(opts, oci.WithUsername(user))
|
opts = append(opts, oci.WithUser(user))
|
||||||
}
|
}
|
||||||
if context.Bool("tty") {
|
if context.Bool("tty") {
|
||||||
opts = append(opts, oci.WithTTY)
|
opts = append(opts, oci.WithTTY)
|
||||||
|
Loading…
Reference in New Issue
Block a user