summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-02-10 11:57:05 -0600
committerAtomic Bot <atomic-devel@projectatomic.io>2018-02-11 10:21:46 +0000
commitd26266659d8649b36b91e8f8f78f8073007554ac (patch)
tree68f943994c26a639f23ba13fa7e024bbe204f41d /cmd
parent773aa61f6622f52696434d883bb82c7d25125fd8 (diff)
downloadpodman-d26266659d8649b36b91e8f8f78f8073007554ac.tar.gz
podman-d26266659d8649b36b91e8f8f78f8073007554ac.tar.bz2
podman-d26266659d8649b36b91e8f8f78f8073007554ac.zip
Honor ENTRYPOINT in image
When an image has an ENTRYPOINT defined, we should be honoring it. The problem is described in issue #321. Also, added buildah binary to test runtimes for testing entrypoint and will also allow us to test podman build as well. Signed-off-by: baude <bbaude@redhat.com> Closes: #322 Approved by: rhatdan
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/common.go2
-rw-r--r--cmd/podman/create.go31
-rw-r--r--cmd/podman/inspect.go3
3 files changed, 23 insertions, 13 deletions
diff --git a/cmd/podman/common.go b/cmd/podman/common.go
index e0aaf52c0..657535e63 100644
--- a/cmd/podman/common.go
+++ b/cmd/podman/common.go
@@ -173,7 +173,7 @@ var createFlags = []cli.Flag{
Name: "dns-search",
Usage: "Set custom DNS search domains",
},
- cli.StringFlag{
+ cli.StringSliceFlag{
Name: "entrypoint",
Usage: "Overwrite the default ENTRYPOINT of the image",
},
diff --git a/cmd/podman/create.go b/cmd/podman/create.go
index 340c036cc..f847b2d22 100644
--- a/cmd/podman/create.go
+++ b/cmd/podman/create.go
@@ -81,7 +81,7 @@ type createConfig struct {
DNSOpt []string //dns-opt
DNSSearch []string //dns-search
DNSServers []string //dns
- Entrypoint string //entrypoint
+ Entrypoint []string //entrypoint
Env map[string]string //env
ExposedPorts map[nat.Port]struct{}
GroupAdd []uint32 // group-add
@@ -419,14 +419,14 @@ func imageData(c *cli.Context, runtime *libpod.Runtime, image string) (string, s
// Parses CLI options related to container creation into a config which can be
// parsed into an OCI runtime spec
func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime, imageName string, data *inspect.ImageData) (*createConfig, error) {
- var command []string
+ var inputCommand, command []string
var memoryLimit, memoryReservation, memorySwap, memoryKernel int64
var blkioWeight uint16
imageID := data.ID
if len(c.Args()) > 1 {
- command = c.Args()[1:]
+ inputCommand = c.Args()[1:]
}
sysctl, err := validateSysctl(c.StringSlice("sysctl"))
@@ -567,15 +567,24 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime, imageName string,
workDir = data.Config.WorkingDir
}
- // COMMAND
- if len(command) == 0 {
- command = data.Config.Cmd
- }
-
// ENTRYPOINT
- entrypoint := c.String("entrypoint")
- if entrypoint == "" {
- entrypoint = strings.Join(data.Config.Entrypoint, " ")
+ // User input entrypoint takes priority over image entrypoint
+ entrypoint := c.StringSlice("entrypoint")
+ if len(entrypoint) == 0 {
+ entrypoint = data.Config.Entrypoint
+ }
+
+ // Build the command
+ // If we have an entry point, it goes first
+ if len(entrypoint) > 0 {
+ command = entrypoint
+ }
+ if len(inputCommand) > 0 {
+ // User command overrides data CMD
+ command = append(command, inputCommand...)
+ } else if len(data.Config.Cmd) > 0 && !c.IsSet("entrypoint") {
+ // If not user command, add CMD
+ command = append(command, data.Config.Cmd...)
}
// EXPOSED PORTS
diff --git a/cmd/podman/inspect.go b/cmd/podman/inspect.go
index ba7b17ed7..84107f3db 100644
--- a/cmd/podman/inspect.go
+++ b/cmd/podman/inspect.go
@@ -2,6 +2,7 @@ package main
import (
"encoding/json"
+ "strings"
specs "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
@@ -223,7 +224,7 @@ func getCtrInspectInfo(ctr *libpod.Container, ctrInspectData *inspect.ContainerI
OpenStdin: config.Stdin,
StopSignal: config.StopSignal,
Cmd: config.Spec.Process.Args,
- Entrypoint: createArtifact.Entrypoint,
+ Entrypoint: strings.Join(createArtifact.Entrypoint, " "),
},
}
return data, nil