mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #10108 from tiborvass/carry-9989
[Carry] Fix a panic where RUN [] would be supplied
This commit is contained in:
commit
eaecf741f0
2 changed files with 26 additions and 3 deletions
|
@ -532,9 +532,13 @@ func (b *Builder) create() (*daemon.Container, error) {
|
||||||
b.TmpContainers[c.ID] = struct{}{}
|
b.TmpContainers[c.ID] = struct{}{}
|
||||||
fmt.Fprintf(b.OutStream, " ---> Running in %s\n", utils.TruncateID(c.ID))
|
fmt.Fprintf(b.OutStream, " ---> Running in %s\n", utils.TruncateID(c.ID))
|
||||||
|
|
||||||
|
if len(config.Cmd) > 0 {
|
||||||
// override the entry point that may have been picked up from the base image
|
// override the entry point that may have been picked up from the base image
|
||||||
c.Path = config.Cmd[0]
|
c.Path = config.Cmd[0]
|
||||||
c.Args = config.Cmd[1:]
|
c.Args = config.Cmd[1:]
|
||||||
|
} else {
|
||||||
|
config.Cmd = []string{}
|
||||||
|
}
|
||||||
|
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,25 @@ import (
|
||||||
"github.com/docker/docker/pkg/archive"
|
"github.com/docker/docker/pkg/archive"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestBuildJSONEmptyRun(t *testing.T) {
|
||||||
|
name := "testbuildjsonemptyrun"
|
||||||
|
defer deleteImages(name)
|
||||||
|
|
||||||
|
_, err := buildImage(
|
||||||
|
name,
|
||||||
|
`
|
||||||
|
FROM busybox
|
||||||
|
RUN []
|
||||||
|
`,
|
||||||
|
true)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal("error when dealing with a RUN statement with empty JSON array")
|
||||||
|
}
|
||||||
|
|
||||||
|
logDone("build - RUN with an empty array should not panic")
|
||||||
|
}
|
||||||
|
|
||||||
func TestBuildEmptyWhitespace(t *testing.T) {
|
func TestBuildEmptyWhitespace(t *testing.T) {
|
||||||
name := "testbuildemptywhitespace"
|
name := "testbuildemptywhitespace"
|
||||||
defer deleteImages(name)
|
defer deleteImages(name)
|
||||||
|
|
Loading…
Reference in a new issue