summaryrefslogtreecommitdiff
path: root/libpod/oci.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2018-02-04 07:29:47 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-02-05 15:39:40 +0000
commit989f5e30627eb90a66fa06f87c40d161476395ed (patch)
tree87b4eabb2bfc27a9d4862db8063cb3cddb98bb23 /libpod/oci.go
parent095aaaa639ab57c594bb80bfefbfaed2a2fdff92 (diff)
downloadpodman-989f5e30627eb90a66fa06f87c40d161476395ed.tar.gz
podman-989f5e30627eb90a66fa06f87c40d161476395ed.tar.bz2
podman-989f5e30627eb90a66fa06f87c40d161476395ed.zip
Pass NOTIFY_SOCKET and LISTEN_FDS env to OCI RUntime if set
In order to have sd_notify from systemd to work in containers we need to pass down the NOTIFY_SOCKET environment variable to the container. LISTEN_FDS, tells the application inside of the container to use socket activation and grab the FDS that are leaked into the container. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Closes: #271 Approved by: umohnani8
Diffstat (limited to 'libpod/oci.go')
-rw-r--r--libpod/oci.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/libpod/oci.go b/libpod/oci.go
index 4183267b8..4ca0bfbef 100644
--- a/libpod/oci.go
+++ b/libpod/oci.go
@@ -13,6 +13,7 @@ import (
"time"
"github.com/containerd/cgroups"
+ "github.com/coreos/go-systemd/activation"
spec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
@@ -210,6 +211,14 @@ func (r *OCIRuntime) createContainer(ctr *Container, cgroupParent string) (err e
// 0, 1 and 2 are stdin, stdout and stderr
cmd.Env = append(r.conmonEnv, fmt.Sprintf("_OCI_SYNCPIPE=%d", 3))
cmd.Env = append(cmd.Env, fmt.Sprintf("_OCI_STARTPIPE=%d", 4))
+ if notify, ok := os.LookupEnv("NOTIFY_SOCKET"); ok {
+ cmd.Env = append(cmd.Env, fmt.Sprintf("NOTIFY_SOCKET=%s", notify))
+ }
+ if listenfds, ok := os.LookupEnv("LISTEN_FDS"); ok {
+ cmd.Env = append(cmd.Env, fmt.Sprintf("LISTEN_FDS=%s", listenfds))
+ fds := activation.Files(false)
+ cmd.ExtraFiles = append(cmd.ExtraFiles, fds...)
+ }
err = cmd.Start()
if err != nil {