diff --git a/containerd/containerd.go b/containerd/containerd.go index d8be647..0735e90 100644 --- a/containerd/containerd.go +++ b/containerd/containerd.go @@ -115,6 +115,11 @@ func (d *Driver) createContainer(containerConfig *ContainerConfig, config *TaskC opts = append(opts, oci.WithDroppedCapabilities(config.CapDrop)) } + // Set current working directory (cwd). + if config.Cwd != "" { + opts = append(opts, oci.WithProcessCwd(config.Cwd)) + } + // Set environment variables. opts = append(opts, oci.WithEnv(containerConfig.Env)) diff --git a/containerd/driver.go b/containerd/driver.go index 4aaa086..35d7826 100644 --- a/containerd/driver.go +++ b/containerd/driver.go @@ -90,6 +90,7 @@ var ( "args": hclspec.NewAttr("args", "list(string)", false), "cap_add": hclspec.NewAttr("cap_add", "list(string)", false), "cap_drop": hclspec.NewAttr("cap_drop", "list(string)", false), + "cwd": hclspec.NewAttr("cwd", "string", false), "devices": hclspec.NewAttr("devices", "list(string)", false), "privileged": hclspec.NewAttr("privileged", "bool", false), "host_dns": hclspec.NewDefault( @@ -146,6 +147,7 @@ type TaskConfig struct { Args []string `codec:"args"` CapAdd []string `codec:"cap_add"` CapDrop []string `codec:"cap_drop"` + Cwd string `codec:"cwd"` Devices []string `codec:"devices"` Seccomp bool `codec:"seccomp"` SeccompProfile string `codec:"seccomp_profile"`