Skip to content

Commit

Permalink
Merge pull request #32236 from tonistiigi/fix-cmd-shell
Browse files Browse the repository at this point in the history
builder: Fix setting command with custom shell
  • Loading branch information
thaJeztah authored Mar 31, 2017
2 parents 9c0473f + a1fa59e commit 05cd8be
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions builder/dockerfile/dispatchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ func errTooManyArguments(command string) error {
// shell-form of RUN, ENTRYPOINT and CMD instructions
func getShell(c *container.Config) []string {
if 0 == len(c.Shell) {
return defaultShell[:]
return append([]string{}, defaultShell[:]...)
}
return c.Shell[:]
return append([]string{}, c.Shell[:]...)
}
15 changes: 15 additions & 0 deletions integration-cli/docker_cli_build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6039,3 +6039,18 @@ func (s *DockerSuite) TestBuildLineErrorWithComments(c *check.C) {
Err: "Dockerfile parse error line 5: Unknown instruction: NOINSTRUCTION",
})
}

// #31957
func (s *DockerSuite) TestBuildSetCommandWithDefinedShell(c *check.C) {
buildImageSuccessfully(c, "build1", build.WithDockerfile(`
FROM busybox
SHELL ["/bin/sh", "-c"]
`))
buildImageSuccessfully(c, "build2", build.WithDockerfile(`
FROM build1
CMD echo foo
`))

out, _ := dockerCmd(c, "inspect", "--format", "{{ json .Config.Cmd }}", "build2")
c.Assert(strings.TrimSpace(out), checker.Equals, `["/bin/sh","-c","echo foo"]`)
}

0 comments on commit 05cd8be

Please sign in to comment.