summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/podman/common/specgen.go18
-rw-r--r--pkg/specgen/generate/oci.go4
-rw-r--r--test/e2e/run_test.go11
3 files changed, 9 insertions, 24 deletions
diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go
index 2333f2f7e..48a2069ff 100644
--- a/cmd/podman/common/specgen.go
+++ b/cmd/podman/common/specgen.go
@@ -387,8 +387,6 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
s.Annotations = annotations
s.WorkDir = c.Workdir
- userCommand := []string{}
- var command []string
if c.Entrypoint != nil {
entrypoint := []string{}
if ep := *c.Entrypoint; len(ep) > 0 {
@@ -398,27 +396,13 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
}
}
s.Entrypoint = entrypoint
- // Build the command
- // If we have an entry point, it goes first
- command = entrypoint
}
// Include the command used to create the container.
s.ContainerCreateCommand = os.Args
if len(inputCommand) > 0 {
- // User command overrides data CMD
- command = append(command, inputCommand...)
- userCommand = append(userCommand, inputCommand...)
- }
-
- switch {
- case len(inputCommand) > 0:
- s.Command = userCommand
- case c.Entrypoint != nil:
- s.Command = []string{}
- default:
- s.Command = command
+ s.Command = inputCommand
}
// SHM Size
diff --git a/pkg/specgen/generate/oci.go b/pkg/specgen/generate/oci.go
index f279aac1c..f1c9f2a1a 100644
--- a/pkg/specgen/generate/oci.go
+++ b/pkg/specgen/generate/oci.go
@@ -96,8 +96,10 @@ func makeCommand(ctx context.Context, s *specgen.SpecGenerator, img *image.Image
finalCommand = append(finalCommand, entrypoint...)
+ // Only use image command if the user did not manually set an
+ // entrypoint.
command := s.Command
- if command == nil && img != nil {
+ if command == nil && img != nil && s.Entrypoint == nil {
newCmd, err := img.Cmd(ctx)
if err != nil {
return nil, err
diff --git a/test/e2e/run_test.go b/test/e2e/run_test.go
index ef275b32e..681498ea1 100644
--- a/test/e2e/run_test.go
+++ b/test/e2e/run_test.go
@@ -1061,13 +1061,12 @@ USER mail`
Expect(session.OutputToString()).To(ContainSubstring(limit))
})
- It("podman run makes entrypoint from image", func() {
- dockerfile := `FROM busybox
-WORKDIR /madethis`
- podmanTest.BuildImage(dockerfile, "test", "false")
- session := podmanTest.Podman([]string{"run", "--rm", "test", "pwd"})
+ It("podman run --entrypoint does not use image command", func() {
+ session := podmanTest.Podman([]string{"run", "--entrypoint", "/bin/echo", ALPINE})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
- Expect(session.OutputToString()).To(ContainSubstring("/madethis"))
+ // We can't guarantee the output is completely empty, some
+ // nonprintables seem to work their way in.
+ Expect(session.OutputToString()).To(Not(ContainSubstring("/bin/sh")))
})
})