summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-03-10 14:25:13 -0400
committerMatthew Heon <matthew.heon@pm.me>2019-03-10 14:25:13 -0400
commit54fd1a7bb962fbce828dd2fb2295518e3c706d8f (patch)
tree69c634978e14f258a1cb78fbb1167c3d19e6b552 /libpod
parenteb3dd9415905b0b66dd8ce30cb6be21939fb4454 (diff)
downloadpodman-54fd1a7bb962fbce828dd2fb2295518e3c706d8f.tar.gz
podman-54fd1a7bb962fbce828dd2fb2295518e3c706d8f.tar.bz2
podman-54fd1a7bb962fbce828dd2fb2295518e3c706d8f.zip
Fix generation of infra container command
When sourcing from an image, we need to grab its entrypoint first and then add command on to mimic the behavior of Docker. The default Kube pause image just sets ENTRYPOINT, and not CMD, so nothing changes there, but this ought to fix other images (for example, nginx would try to run the pause command instead of an nginx process without this patch) Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/runtime_pod_infra_linux.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/libpod/runtime_pod_infra_linux.go b/libpod/runtime_pod_infra_linux.go
index 6b07bcb31..0a5f78cf8 100644
--- a/libpod/runtime_pod_infra_linux.go
+++ b/libpod/runtime_pod_infra_linux.go
@@ -12,6 +12,7 @@ import (
spec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-tools/generate"
"github.com/pkg/errors"
+ "github.com/sirupsen/logrus"
)
const (
@@ -34,9 +35,24 @@ func (r *Runtime) makeInfraContainer(ctx context.Context, p *Pod, imgName, imgID
// I've seen circumstances where config is being passed as nil.
// Let's err on the side of safety and make sure it's safe to use.
if config != nil {
+ setEntrypoint := false
// default to entrypoint in image if there is one
if len(config.Entrypoint) > 0 {
entryCmd = config.Entrypoint
+ setEntrypoint = true
+ }
+ if len(config.Cmd) > 0 {
+ // We can't use the default pause command, since we're
+ // sourcing from the image. If we didn't already set an
+ // entrypoint, set one now.
+ if !setEntrypoint {
+ // Use the Docker default "/bin/sh -c"
+ // entrypoint, as we're overriding command.
+ // If an image doesn't want this, it can
+ // override entrypoint too.
+ entryCmd = []string{"/bin/sh", "-c"}
+ }
+ entryCmd = append(entryCmd, config.Cmd...)
}
if len(config.Env) > 0 {
for _, nameValPair := range config.Env {
@@ -52,6 +68,8 @@ func (r *Runtime) makeInfraContainer(ctx context.Context, p *Pod, imgName, imgID
g.SetRootReadonly(true)
g.SetProcessArgs(entryCmd)
+ logrus.Debugf("Using %q as infra container entrypoint", entryCmd)
+
if isRootless {
g.RemoveMount("/dev/pts")
devPts := spec.Mount{