From 78a847a47ac777f4090c06a82e875ee30f9a1cbd Mon Sep 17 00:00:00 2001 From: Erik Hollensbe Date: Mon, 1 Sep 2014 13:33:06 -0700 Subject: [PATCH] evaluator: ensure entrypoint stays blank if set blank while CMD is set. Docker-DCO-1.1-Signed-off-by: Erik Hollensbe (github: erikh) --- builder/dispatchers.go | 6 ++---- integration-cli/docker_cli_build_test.go | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/builder/dispatchers.go b/builder/dispatchers.go index 4d1d2135de..201a76ada4 100644 --- a/builder/dispatchers.go +++ b/builder/dispatchers.go @@ -255,11 +255,9 @@ func cmd(b *Builder, args []string, attributes map[string]bool) error { func entrypoint(b *Builder, args []string, attributes map[string]bool) error { b.Config.Entrypoint = handleJsonArgs(args, attributes) - if len(b.Config.Entrypoint) == 0 { + if len(b.Config.Entrypoint) == 0 && len(b.Config.Cmd) == 0 { b.Config.Entrypoint = []string{"/bin/sh", "-c"} - } - - if !b.cmdSet { + } else if !b.cmdSet { b.Config.Cmd = nil } diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index 1dc8896952..6860abf453 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -791,6 +791,25 @@ func TestBuildEntrypoint(t *testing.T) { if res != expected { t.Fatalf("Entrypoint %s, expected %s", res, expected) } + + deleteImages(name) + expected = "[]" + + _, err = buildImage(name, + `FROM busybox + ENTRYPOINT []`, + true) + if err != nil { + t.Fatal(err) + } + res, err = inspectField(name, "Config.Entrypoint") + if err != nil { + t.Fatal(err) + } + if res != expected { + t.Fatalf("Entrypoint %s, expected %s", res, expected) + } + logDone("build - entrypoint") }