diff --git a/api/agent/agent.go b/api/agent/agent.go index fcc2fc179..f8979ed27 100644 --- a/api/agent/agent.go +++ b/api/agent/agent.go @@ -219,6 +219,7 @@ func NewDockerDriver(cfg *Config) (drivers.Driver, error) { PreForkNetworks: cfg.PreForkNetworks, MaxTmpFsInodes: cfg.MaxTmpFsInodes, EnableReadOnlyRootFs: !cfg.DisableReadOnlyRootFs, + EnableTini: !cfg.DisableTini, }) } diff --git a/api/agent/config.go b/api/agent/config.go index a8e3fdb05..cd24697c9 100644 --- a/api/agent/config.go +++ b/api/agent/config.go @@ -33,6 +33,7 @@ type Config struct { EnableNBResourceTracker bool `json:"enable_nb_resource_tracker"` MaxTmpFsInodes uint64 `json:"max_tmpfs_inodes"` DisableReadOnlyRootFs bool `json:"disable_readonly_rootfs"` + DisableTini bool `json:"disable_tini"` DisableDebugUserLogs bool `json:"disable_debug_user_logs"` } @@ -84,6 +85,8 @@ const ( EnvMaxTmpFsInodes = "FN_MAX_TMPFS_INODES" // EnvDisableReadOnlyRootFs makes the root fs for a container have rw permissions, by default it is read only EnvDisableReadOnlyRootFs = "FN_DISABLE_READONLY_ROOTFS" + // EnvDisableTini runs containers without using the --init option, for tini pid 1 action + EnvDisableTini = "FN_DISABLE_TINI" // EnvDisableDebugUserLogs disables user function logs being logged at level debug. wise to enable for production. EnvDisableDebugUserLogs = "FN_DISABLE_DEBUG_USER_LOGS" diff --git a/api/agent/drivers/docker/docker.go b/api/agent/drivers/docker/docker.go index 0a3b4ac47..f97dd039c 100644 --- a/api/agent/drivers/docker/docker.go +++ b/api/agent/drivers/docker/docker.go @@ -223,6 +223,7 @@ func (drv *DockerDriver) CreateCookie(ctx context.Context, task drivers.Containe }, HostConfig: &docker.HostConfig{ ReadonlyRootfs: drv.conf.EnableReadOnlyRootFs, + Init: drv.conf.EnableTini, }, Context: ctx, } diff --git a/api/agent/drivers/driver.go b/api/agent/drivers/driver.go index 39665b806..95b7158bd 100644 --- a/api/agent/drivers/driver.go +++ b/api/agent/drivers/driver.go @@ -224,6 +224,8 @@ const ( ) type Config struct { + // TODO this should all be driver-specific config and not in the + // driver package itself. fix if we ever one day try something else Docker string `json:"docker"` DockerNetworks string `json:"docker_networks"` DockerLoadFile string `json:"docker_load_file"` @@ -235,6 +237,7 @@ type Config struct { PreForkNetworks string `json:"pre_fork_networks"` MaxTmpFsInodes uint64 `json:"max_tmpfs_inodes"` EnableReadOnlyRootFs bool `json:"enable_readonly_rootfs"` + EnableTini bool `json:"enable_tini"` } func average(samples []Stat) (Stat, bool) {