1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fix builder when num of RUN args is 1

FROM scratch
ADD echo /
RUN [ "echo" ]

will die with
  exec: "/bin/sh": stat /bin/sh: no such file or directory

Signed-off-by: Doug Davis <dug@us.ibm.com>
This commit is contained in:
Doug Davis 2015-03-09 14:44:14 -07:00
parent 13bfbfc84b
commit 645f8a32df
4 changed files with 32 additions and 3 deletions

View file

@ -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

View file

@ -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)

View file

@ -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")
}

View file

@ -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