summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2018-08-21 07:31:00 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2018-08-31 14:42:32 -0400
commit27ca091c08674b1a34058c9639d60455023ffa30 (patch)
tree04bc6d9e5ab9b19e7728a90ff4d48b0e4efe515f /cmd
parenta917f8fa2a0d9130d84bfda0c40bfe1af68d505c (diff)
downloadpodman-27ca091c08674b1a34058c9639d60455023ffa30.tar.gz
podman-27ca091c08674b1a34058c9639d60455023ffa30.tar.bz2
podman-27ca091c08674b1a34058c9639d60455023ffa30.zip
Add proper support for systemd inside of podman
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/common.go4
-rw-r--r--cmd/podman/create.go15
2 files changed, 18 insertions, 1 deletions
diff --git a/cmd/podman/common.go b/cmd/podman/common.go
index 93b16f4e3..43a0fe061 100644
--- a/cmd/podman/common.go
+++ b/cmd/podman/common.go
@@ -383,6 +383,10 @@ var createFlags = []cli.Flag{
Name: "sysctl",
Usage: "Sysctl options (default [])",
},
+ cli.BoolTFlag{
+ Name: "systemd",
+ Usage: "Run container in systemd mode if the command executable is systemd or init",
+ },
cli.StringSliceFlag{
Name: "tmpfs",
Usage: "Mount a temporary filesystem (`tmpfs`) into a container (default [])",
diff --git a/cmd/podman/create.go b/cmd/podman/create.go
index 209064eff..e7e349306 100644
--- a/cmd/podman/create.go
+++ b/cmd/podman/create.go
@@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"os"
+ "path/filepath"
"strconv"
"strings"
"syscall"
@@ -509,7 +510,7 @@ func parseCreateOpts(ctx context.Context, c *cli.Context, runtime *libpod.Runtim
// STOP SIGNAL
stopSignal := syscall.SIGTERM
- signalString := "SIGTERM"
+ signalString := ""
if data != nil {
signalString = data.ContainerConfig.StopSignal
}
@@ -648,6 +649,17 @@ func parseCreateOpts(ctx context.Context, c *cli.Context, runtime *libpod.Runtim
return nil, errors.Errorf("invalid image-volume type %q. Pick one of bind, tmpfs, or ignore", c.String("image-volume"))
}
+ var systemd bool
+ if c.BoolT("systemd") && ((filepath.Base(command[0]) == "init") || (filepath.Base(command[0]) == "systemd")) {
+ systemd = true
+ if signalString == "" {
+ stopSignal, err = signal.ParseSignal("RTMIN+3")
+ if err != nil {
+ return nil, errors.Wrapf(err, "error parsing systemd signal")
+ }
+ }
+ }
+
config := &cc.CreateConfig{
Runtime: runtime,
Annotations: annotations,
@@ -726,6 +738,7 @@ func parseCreateOpts(ctx context.Context, c *cli.Context, runtime *libpod.Runtim
StopSignal: stopSignal,
StopTimeout: c.Uint("stop-timeout"),
Sysctl: sysctl,
+ Systemd: systemd,
Tmpfs: c.StringSlice("tmpfs"),
Tty: tty,
User: user,