evaluator: ensure entrypoint stays blank if set blank while CMD is set.
Docker-DCO-1.1-Signed-off-by: Erik Hollensbe <github@hollensbe.org> (github: erikh)
This commit is contained in:
parent
ac107995ae
commit
78a847a47a
|
@ -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 {
|
func entrypoint(b *Builder, args []string, attributes map[string]bool) error {
|
||||||
b.Config.Entrypoint = handleJsonArgs(args, attributes)
|
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"}
|
b.Config.Entrypoint = []string{"/bin/sh", "-c"}
|
||||||
}
|
} else if !b.cmdSet {
|
||||||
|
|
||||||
if !b.cmdSet {
|
|
||||||
b.Config.Cmd = nil
|
b.Config.Cmd = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -791,6 +791,25 @@ func TestBuildEntrypoint(t *testing.T) {
|
||||||
if res != expected {
|
if res != expected {
|
||||||
t.Fatalf("Entrypoint %s, expected %s", 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")
|
logDone("build - entrypoint")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue