Skip to content

Commit 78a847a

Browse files
author
Erik Hollensbe
committed
evaluator: ensure entrypoint stays blank if set blank while CMD is set.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <[email protected]> (github: erikh)
1 parent ac10799 commit 78a847a

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

builder/dispatchers.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,9 @@ func cmd(b *Builder, args []string, attributes map[string]bool) error {
255255
func entrypoint(b *Builder, args []string, attributes map[string]bool) error {
256256
b.Config.Entrypoint = handleJsonArgs(args, attributes)
257257

258-
if len(b.Config.Entrypoint) == 0 {
258+
if len(b.Config.Entrypoint) == 0 && len(b.Config.Cmd) == 0 {
259259
b.Config.Entrypoint = []string{"/bin/sh", "-c"}
260-
}
261-
262-
if !b.cmdSet {
260+
} else if !b.cmdSet {
263261
b.Config.Cmd = nil
264262
}
265263

integration-cli/docker_cli_build_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,25 @@ func TestBuildEntrypoint(t *testing.T) {
791791
if res != expected {
792792
t.Fatalf("Entrypoint %s, expected %s", res, expected)
793793
}
794+
795+
deleteImages(name)
796+
expected = "[]"
797+
798+
_, err = buildImage(name,
799+
`FROM busybox
800+
ENTRYPOINT []`,
801+
true)
802+
if err != nil {
803+
t.Fatal(err)
804+
}
805+
res, err = inspectField(name, "Config.Entrypoint")
806+
if err != nil {
807+
t.Fatal(err)
808+
}
809+
if res != expected {
810+
t.Fatalf("Entrypoint %s, expected %s", res, expected)
811+
}
812+
794813
logDone("build - entrypoint")
795814
}
796815

0 commit comments

Comments
 (0)