No entrpoint, cmd, or command

When an image does not have an ENTRYPOINT nor a CMD and the
user does not provide a command in the CLI, we should fail
gracefully.

This resolves issue #328

Signed-off-by: baude <bbaude@redhat.com>

Closes: #333
Approved by: mheon
This commit is contained in:
baude
2018-02-14 15:25:06 -06:00
committed by Atomic Bot
parent be9ed1cfac
commit e814936915
2 changed files with 15 additions and 0 deletions

View File

@ -587,6 +587,10 @@ func parseCreateOpts(c *cli.Context, runtime *libpod.Runtime, imageName string,
command = append(command, data.ContainerConfig.Cmd...) command = append(command, data.ContainerConfig.Cmd...)
} }
if len(command) == 0 {
return nil, errors.Errorf("No command specified on command line or as CMD or ENTRYPOINT in this image")
}
// EXPOSED PORTS // EXPOSED PORTS
portBindings, err := exposedPorts(c, data.ContainerConfig.ExposedPorts) portBindings, err := exposedPorts(c, data.ContainerConfig.ExposedPorts)
if err != nil { if err != nil {

View File

@ -28,6 +28,17 @@ var _ = Describe("Podman run entrypoint", func() {
}) })
It("podman run no command, entrypoint, or cmd", func() {
dockerfile := `FROM docker.io/library/alpine:latest
ENTRYPOINT []
CMD []
`
podmanTest.BuildImage(dockerfile, "foobar.com/entrypoint:latest")
session := podmanTest.Podman([]string{"run", "foobar.com/entrypoint:latest"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(125))
})
It("podman run entrypoint", func() { It("podman run entrypoint", func() {
dockerfile := `FROM docker.io/library/alpine:latest dockerfile := `FROM docker.io/library/alpine:latest
ENTRYPOINT ["grep", "Alpine", "/etc/os-release"] ENTRYPOINT ["grep", "Alpine", "/etc/os-release"]