I'm running an example from the O'Reilly book Kubernetes Up & Running, but it gives me a build error, which I'm trying to debug.
When I type docker build -t kuard .
I get this build error:
=> ERROR [9/9] RUN build/build.sh
------
> [9/9] RUN build/build.sh:
0.162 /bin/sh: build/build.sh: not found
------
To begin my debugging, I decided to look at what's in the directory, so I inserted the pwd
and ls -aF
commands. This approach is suggested by the Docker help page at
It didn't help. Now my output looks like this:
=> CACHED [6/9] COPY . . 0.0s
=> CACHED [7/9] RUN pwd 0.0s
=> CACHED [8/9] RUN ls -aF 0.0s
=> ERROR [9/9] RUN build/build.sh 0.2s
------
> [9/9] RUN build/build.sh:
0.175 /bin/sh: build/build.sh: not found
------
So my narrow question is this: How do I get the results of the pwd
and ls -aF
commands in Docker? But my broader question is this: How do I debug a Docker file?
Here's the whole Docker file. The directory has no other contents.
FROM golang:1.11-alpine
# Install Node and NPM
RUN apk update && apk upgrade && apk add --no-cache git nodejs bash npm
# Get dependencies for Go part of build
RUN go get -u github/jteeuwen/go-bindata/...
RUN go get github/tools/godep
WORKDIR /go/src/github/kubernetes-up-and-running/kuard
# Copy all sources in
COPY . .
# This is a set of variables that the build script expects
ENV VERBOSE=0
ENV PKG=github/kubernetes-up-and-running/kuard
ENV ARCH=amd64
ENV VERSION=test
# Do the build. This script is part of incoming sources.
RUN pwd
RUN ls -aF
RUN build/build.sh
CMD [ "/go/bin/kuard" ]
I also tried commenting out the RUN build/build.sh
command, but I still didn't see the results of the pwd
or ls -aF
commands.
I'm running an example from the O'Reilly book Kubernetes Up & Running, but it gives me a build error, which I'm trying to debug.
When I type docker build -t kuard .
I get this build error:
=> ERROR [9/9] RUN build/build.sh
------
> [9/9] RUN build/build.sh:
0.162 /bin/sh: build/build.sh: not found
------
To begin my debugging, I decided to look at what's in the directory, so I inserted the pwd
and ls -aF
commands. This approach is suggested by the Docker help page at https://www.docker.com/blog/how-to-fix-and-debug-docker-containers-like-a-superhero/#Docker%20Build
It didn't help. Now my output looks like this:
=> CACHED [6/9] COPY . . 0.0s
=> CACHED [7/9] RUN pwd 0.0s
=> CACHED [8/9] RUN ls -aF 0.0s
=> ERROR [9/9] RUN build/build.sh 0.2s
------
> [9/9] RUN build/build.sh:
0.175 /bin/sh: build/build.sh: not found
------
So my narrow question is this: How do I get the results of the pwd
and ls -aF
commands in Docker? But my broader question is this: How do I debug a Docker file?
Here's the whole Docker file. The directory has no other contents.
FROM golang:1.11-alpine
# Install Node and NPM
RUN apk update && apk upgrade && apk add --no-cache git nodejs bash npm
# Get dependencies for Go part of build
RUN go get -u github.com/jteeuwen/go-bindata/...
RUN go get github.com/tools/godep
WORKDIR /go/src/github.com/kubernetes-up-and-running/kuard
# Copy all sources in
COPY . .
# This is a set of variables that the build script expects
ENV VERBOSE=0
ENV PKG=github.com/kubernetes-up-and-running/kuard
ENV ARCH=amd64
ENV VERSION=test
# Do the build. This script is part of incoming sources.
RUN pwd
RUN ls -aF
RUN build/build.sh
CMD [ "/go/bin/kuard" ]
I also tried commenting out the RUN build/build.sh
command, but I still didn't see the results of the pwd
or ls -aF
commands.
Thanks you to DazWilkin for debugging my build. Now that I can build, I can see how to get the output of the pwd
and ls -aF
commands. When I build, the output ends with this line:
View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/c92k(moreGarbage)...
When I copy that URL into my browser, it opens my docker-desktop and displays my build output. The log button shows, among other things, the output of the pwd
and ls -aF
commands.
COPY . .
expects (I think the cloned source of kuard). What command are you using to build the container. Ifdocker
orpodman
, you can append--no-cache
to stop layers being cached during the build thereby omitting your debugging output. – DazWilkin Commented Jan 7 at 1:58docker ps -a
, I don't see any images, because, of course, my build failed. – MiguelMunoz Commented Jan 7 at 1:59RUN go get ...
commands in the build file. I'm building usingdocker build -t kuard .
Thanks for pointing that out. I will add it to my description. – MiguelMunoz Commented Jan 7 at 2:06build/build.sh
exist in your local source tree? What is the very first line of the script? (If it's#!/bin/bash
, Alpine-based images don't have bash.) Is there any chance you're working on a Windows host and the file has DOS line endings (which would make the interpreter be/bin/sh\r
)? – David Maze Commented Jan 7 at 2:11