From d101e9c5b36104a6f9e948c4baef7bcff0be6341 Mon Sep 17 00:00:00 2001 From: Shishir Mahajan Date: Thu, 12 Nov 2020 11:34:56 -0800 Subject: [PATCH] Add option to select current working directory (cwd). --- containerd/containerd.go | 5 +++++ containerd/driver.go | 2 ++ 2 files changed, 7 insertions(+) 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"`