commit
ec43dc2b46
@ -89,6 +89,10 @@ var runCommand = cli.Command{
|
||||
Name: "checkpoint",
|
||||
Usage: "provide the checkpoint digest to restore the container",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "cwd",
|
||||
Usage: "specify the working directory of the process",
|
||||
},
|
||||
}, snapshotterFlags...),
|
||||
Action: func(context *cli.Context) error {
|
||||
var (
|
||||
|
@ -107,6 +107,9 @@ func newContainer(ctx gocontext.Context, client *containerd.Client, context *cli
|
||||
if len(args) > 0 {
|
||||
opts = append(opts, containerd.WithProcessArgs(args...))
|
||||
}
|
||||
if cwd := context.String("cwd"); cwd != "" {
|
||||
opts = append(opts, containerd.WithProcessCwd(cwd))
|
||||
}
|
||||
if context.Bool("tty") {
|
||||
opts = append(opts, withTTY())
|
||||
}
|
||||
|
@ -107,7 +107,9 @@ func newContainer(ctx gocontext.Context, client *containerd.Client, context *cli
|
||||
if len(args) > 0 {
|
||||
opts = append(opts, containerd.WithProcessArgs(args...))
|
||||
}
|
||||
|
||||
if cwd := context.String("cwd"); cwd != "" {
|
||||
opts = append(opts, containerd.WithProcessCwd(cwd))
|
||||
}
|
||||
return client.NewContainer(ctx, id,
|
||||
containerd.WithNewSpec(opts...),
|
||||
containerd.WithContainerLabels(labels),
|
||||
|
@ -19,6 +19,14 @@ func WithProcessArgs(args ...string) SpecOpts {
|
||||
}
|
||||
}
|
||||
|
||||
// WithProcessCwd replaces the current working directory on the generated spec
|
||||
func WithProcessCwd(cwd string) SpecOpts {
|
||||
return func(_ context.Context, _ *Client, _ *containers.Container, s *specs.Spec) error {
|
||||
s.Process.Cwd = cwd
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// WithHostname sets the container's hostname
|
||||
func WithHostname(name string) SpecOpts {
|
||||
return func(_ context.Context, _ *Client, _ *containers.Container, s *specs.Spec) error {
|
||||
|
Loading…
Reference in New Issue
Block a user