Skip to content

Commit

Permalink
Merge pull request moby#11265 from duglin/ScratchSHfix
Browse files Browse the repository at this point in the history
Fix builder when num of RUN args is 1
  • Loading branch information
tiborvass committed Mar 12, 2015
2 parents 5d174e0 + 645f8a3 commit 565cff8
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ RUN ln -sfv $PWD/.bashrc ~/.bashrc
# Get useful and necessary Hub images so we can "docker load" locally instead of pulling
COPY contrib/download-frozen-image.sh /go/src/github.com/docker/docker/contrib/
RUN ./contrib/download-frozen-image.sh /docker-frozen-images \
busybox:latest@4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125
busybox:latest@4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125 \
hello-world:latest@e45a5af57b00862e5ef5782a9925979a02ba2b12dff832fd0991335f4a11e5c5
# see also "hack/make/.ensure-frozen-images" (which needs to be updated any time this list is)

# Install man page generator
Expand Down
4 changes: 2 additions & 2 deletions builder/dispatchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ func run(b *Builder, args []string, attributes map[string]bool, original string)

args = handleJsonArgs(args, attributes)

if len(args) == 1 {
args = append([]string{"/bin/sh", "-c"}, args[0])
if !attributes["json"] {
args = append([]string{"/bin/sh", "-c"}, args...)
}

runCmd := flag.NewFlagSet("run", flag.ContinueOnError)
Expand Down
27 changes: 27 additions & 0 deletions integration-cli/docker_cli_build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5227,3 +5227,30 @@ func TestBuildNotVerbose(t *testing.T) {

logDone("build - not verbose")
}

func TestBuildRUNoneJSON(t *testing.T) {
name := "testbuildrunonejson"

defer deleteAllContainers()
defer deleteImages(name)

ctx, err := fakeContext(`FROM hello-world:latest
RUN [ "/hello" ]`, map[string]string{})
if err != nil {
t.Fatal(err)
}
defer ctx.Close()

buildCmd := exec.Command(dockerBinary, "build", "--no-cache", "-t", name, ".")
buildCmd.Dir = ctx.Dir
out, _, err := runCommandWithOutput(buildCmd)
if err != nil {
t.Fatalf("failed to build the image: %s, %v", out, err)
}

if !strings.Contains(out, "Hello from Docker") {
t.Fatalf("bad output: %s", out)
}

logDone("build - RUN with one JSON arg")
}
1 change: 1 addition & 0 deletions project/make/.ensure-frozen-images
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -e
# this list should match roughly what's in the Dockerfile (minus the explicit image IDs, of course)
images=(
busybox:latest
hello-world:latest
)

if ! docker inspect "${images[@]}" &> /dev/null; then
Expand Down

0 comments on commit 565cff8

Please sign in to comment.