diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-03-16 14:40:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-16 14:40:02 +0100 |
commit | 412a114d33a2f0aca7ee49984afcf278d2f2574a (patch) | |
tree | 2d3c74c57531a218615d4d16b768034242cc62de /pkg/systemd/generate/systemdgen.go | |
parent | 5288d112bc63bb52821a0ed9711fcc23b37df2a8 (diff) | |
parent | 194723f314f505de3d39afb7fd769bc02293fd88 (diff) | |
download | podman-412a114d33a2f0aca7ee49984afcf278d2f2574a.tar.gz podman-412a114d33a2f0aca7ee49984afcf278d2f2574a.tar.bz2 podman-412a114d33a2f0aca7ee49984afcf278d2f2574a.zip |
Merge pull request #5439 from ttys3/fixup-systemdgen-with-new-param
systemd generator: force run container detached if CreateCommand has no detach param
Diffstat (limited to 'pkg/systemd/generate/systemdgen.go')
-rw-r--r-- | pkg/systemd/generate/systemdgen.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/pkg/systemd/generate/systemdgen.go b/pkg/systemd/generate/systemdgen.go index 4410e1395..4cd7745c0 100644 --- a/pkg/systemd/generate/systemdgen.go +++ b/pkg/systemd/generate/systemdgen.go @@ -164,6 +164,26 @@ func CreateContainerSystemdUnit(info *ContainerInfo, opts Options) (string, erro "--cidfile", "%t/%n-cid", "--cgroups=no-conmon", } + + // Enforce detaching + // + // since we use systemd `Type=forking` service + // @see https://www.freedesktop.org/software/systemd/man/systemd.service.html#Type= + // when we generated systemd service file with the --new param, + // `ExecStart` will have `/usr/bin/podman run ...` + // if `info.CreateCommand` has no `-d` or `--detach` param, + // podman will run the container in default attached mode, + // as a result, `systemd start` will wait the `podman run` command exit until failed with timeout error. + hasDetachParam := false + for _, p := range info.CreateCommand[index:] { + if p == "--detach" || p == "-d" { + hasDetachParam = true + } + } + if !hasDetachParam { + command = append(command, "-d") + } + command = append(command, info.CreateCommand[index:]...) info.RunCommand = strings.Join(command, " ") info.New = true |