Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build.sh not found when doing docker build #30

Open
zhoucengchao opened this issue Jan 7, 2020 · 33 comments
Open

build.sh not found when doing docker build #30

zhoucengchao opened this issue Jan 7, 2020 · 33 comments
Assignees

Comments

@zhoucengchao
Copy link

zhoucengchao commented Jan 7, 2020

Hi,
I followed the procedures of multi-stage image build described in chapter 2 but was getting the build.sh not found problem.

$ docker build -t kuard .
.......
Step 11/12 : RUN build/build.sh
---> Running in 1119265327a0
/bin/sh: build/build.sh: not found

Did I miss anything or should I modify something rather than copy paste the content of the Dockerfile? Do I need to clone the the ./kuard to /go/src/github.com/kubernetes-up-and-running/kuard onto my Mac local filesystem? / is read-only on macOS Catalina BTW.
Thanks!

@jastis77
Copy link

I have the exact same issue . Running Docker Desktop for Windows 2.2.
Step 10/14 : RUN build/build.sh
---> Running in 32c9d6d4aff7
/bin/sh: build/build.sh: not found
The command '/bin/sh -c build/build.sh' returned a non-zero code: 127

@wbanguna
Copy link

wbanguna commented Feb 1, 2020

Try this:

  1. go get github.com/kubernetes-up-and-running/kuard
  2. cd into directory, probably GOPATH/src/github.com/kubernetes-up-and-running/kuard
  3. docker build -t kuard .

@arkfen
Copy link

arkfen commented Feb 10, 2020

Try this:

  1. go get github.com/kubernetes-up-and-running/kuard
  2. cd into directory, probably GOPATH/src/github.com/kubernetes-up-and-running/kuard
  3. docker build -t kuard .

even doing so still getting this:

Step 9/14 : ENV VERSION=test
---> Running in f9a4a90a95dc
Removing intermediate container f9a4a90a95dc
---> 2868f0e1957c
Step 10/14 : RUN build/build.sh
---> Running in c8ca9ae76872
/bin/sh: build/build.sh: not found
The command '/bin/sh -c build/build.sh' returned a non-zero code: 127

@jbeda
Copy link
Member

jbeda commented Feb 12, 2020

Sorry I haven't gotten to this! I'll try to fix it this weekend.

@jbeda jbeda self-assigned this Feb 12, 2020
@funkybrown
Copy link

yes me too it looks like its not copying the build directory when you ls the working directory or something

@andyw8
Copy link

andyw8 commented Feb 17, 2020

I'm also running into this.

❯ docker -v
Docker version 19.03.1, build 74b1e89

@andyw8
Copy link

andyw8 commented Feb 17, 2020

Update: If I download this repo as a zip, then I'm able to build the image, after setting chmod +x on build/build.sh.

I think the chapter is assuming the necessary directories (e.g. build/ and client/) are already present on your local machine alongside the Dockerfile.

@jbeda
Copy link
Member

jbeda commented Feb 22, 2020

Hey all -- i'm having a hard time reproducing this!

Some quick questions to help narrow this down:

  • How did you install the repo? git clone? go get? Download zip?
  • If you used go get what version did you use (go version) and what command did you type?
  • What version of docker are you running?
  • Does clearing the docker build cache (docker builder prune) help? If you are willing, a docker system prune -a will really clean things out. But that may delete data volumes you care about so be careful.
  • What OS and version are you on?

As for me, I'm doing a git clone outside of my $GOPATH, going into that directory and doing a simple docker build -t kuard .. I'm on macOS Catalina with Docker version 19.03.5, build 633a0ea.

Or is it that the instructions in the book don't make it clear that you need the whole repo? (If so I'm sorry about that!)

@jbeda
Copy link
Member

jbeda commented Feb 22, 2020

I created a quick video for how it works for me. Hopefully this'll be helpful for folks:
https://www.youtube.com/watch?v=2DB74KoZCNU&feature=youtu.be

@arkfen
Copy link

arkfen commented Feb 23, 2020

First of all thanks for your hard work and great video... Secondly - unfortunately after following your steps I got the same result as you can see... I have the same version of the Docker.. I ignored the instruction of cloning to the folder our of the Go path because as far as I know I do not have GO installed on this PC at all.. I run Win 10 Pro and I have cloned to C:\Code\kuard and I also pruned the docker prior to the build... hm... any ideas?

I tried few times before - started with just book instructions and then switched to this Git repo and cloning...

image

@arkfen
Copy link

arkfen commented Feb 23, 2020

PS now I am pretty new to docker and I have absolutely no experience with GO... now I am not sure - perhaps PC must have GO installed after all in order to build this image? Or when it downloads alpine - go image it is building other stuff already from the container and I no need GO or even Node to be installed locally?

@wiardvanrij
Copy link

@arkfen
Could you check in Docker for Windows if your C: drive is actually shared?

Docker for Windows -> Settings -> Shared Drivers -> Enabled for C:

@arkfen
Copy link

arkfen commented Feb 23, 2020

yes, I think so... please double check with my screenshot if this is what you mean

image

@jbeda
Copy link
Member

jbeda commented Feb 27, 2020

Hey all -- clearly this is an issue that only happens on Windows. I'm traveling this week and don't have easy access to a windows machine (should probably set up a VM). I'll try and dig in this weekened.

@Chike-O
Copy link

Chike-O commented Mar 14, 2020

I am experiencing the same issue; I am running Docker on a Windows 10 machine. Please let us know your findings when you try it out on Windows 10.

@harkanwals
Copy link

harkanwals commented Mar 20, 2020

I had the same issue on macOS Catalina, version 10.15.3. Docker version 19.03.5, build 633a0ea.

Just posting it here in case anyone comes with same issue from the book.

I was running the script directly from the book, without cloning the Git repo.

Then, I cloned the repo, as per directions from @jbeda and just ran the Dockerfile there and it worked like a charm. Hopefully, this helps someone.

@aryo-ps
Copy link

aryo-ps commented Mar 23, 2020

I am also facing this issue on Centos 7.
this issue comes when you running the Dockerfile outside the repo directory.
make sure you have installed git.

Solved:

  1. git clone https://github.com/kubernetes-up-and-running/kuard.git
  2. cd /kuard
  3. run command make
  4. run you Dockerfile inside Kuard directory

@stanlearn777
Copy link

I am experiencing the same issue; I am running Docker on a Windows 10 Pro machine.
Please, let me know of your findings on Windows 10 Pro. Thanks.

@djfrmd
Copy link
Contributor

djfrmd commented Mar 30, 2020

There are windows line endings in the repo. It is not working for windows because of the shebang in build/build.sh

If you remove the ^M from all lines in the *.sh files it works fine on windows. The link below talks about how to fix this for the repo.

https://help.github.com/en/github/using-git/configuring-git-to-handle-line-endings#per-repository-settings

@os-learner
Copy link

I'm also getting the same exact error message.
Please advise.
I'm trying to build kuard on a windows PC.

Step 10/14 : RUN build/build.sh
---> Running in 1efb2a68c367
/bin/sh: build/build.sh: not found
The command '/bin/sh -c build/build.sh' returned a non-zero code: 127

image

@os-learner
Copy link

arkfen,
Is it working for you?
jbode,
Any advise on how to get this working?

@djfrmd
Copy link
Contributor

djfrmd commented Apr 16, 2020

@os-learner can you change all CRLFs to LFs in the *.sh files and re-run? I created a pull request with this done.

I am relatively certain this is the issue most people are seeing on Windows devices where git-for-windows is handling line endings for the repo based on user settings.

@os-learner
Copy link

@djfrmd ,
Thanks. I downloaded Notepad++ and did extended search to find "\r\n" with \n" and saved the build.sh file.
I executed build then and it worked without any issues.
Thanks for your help.

@isaacsgi
Copy link

@xt94c4t9ce
Copy link

I ran in to this same situation.

Or is it that the instructions in the book don't make it clear that you need the whole repo?

In my case this was indeed the problem. If the book told me to download the repository and run docker inside of it, I missed this part. I guess the download may be obvious to folks with docker experience, but I'm new to it. Thanks and have a great day!

@philippw
Copy link

philippw commented May 7, 2020

@jbeda Please integrate the line-endings fix #31. This saves a lot of headaches for Windows 10 users.

This fix prevents git from converting line-endings on checkout.

For everyone else: if you get docker /bin/sh: build/build.sh: not found you are probably using docker-cli or Docker for Windows and git is configured to convert CR (Unix line-endings) to CR/LF (Windows line-endings) on checkout.

All you need to do to resolve this, is to convert build/build.sh from using CR instead of CR/LF. See comments above, to find out on how to do this for several popular editors.

@Niedman
Copy link

Niedman commented Jun 14, 2020

I had the same issue so I clone the repository and you will notice that there is already a Dockerfile with multistage similar to the one you allegedly have created just before. You can delete yours or just replace it by the current Dockerfile.

When inside the folder kuard you can simply run the command that is on the book:
docker build -t kuard .

Hope it helps.

@arkfen
Copy link

arkfen commented Aug 23, 2020

arkfen,
Is it working for you?
jbode,
Any advise on how to get this working?

oh yeah! thanks a lot! it worked just after changing line ending in the notepad++ - took me 20 seconds )) I just did not check the issue for few months and finally found time to do it... and fix it. I hope everyone else got the issue solved... I am not pro regarding line endings for different OSs but if there is a way to leave it the way which works everywhere - it would be nice.. then it would work on Windows right away

image

@simcikdt
Copy link

simcikdt commented Oct 25, 2020

I downloaded kuard-master from GitHub, copied the multi-stage Dockerfile to a new directory on my Windows 10 laptop, then tried running the Docker build, which still failed on the build.sh step. As an alternative, I changed into the kuard-master (unzipped) directory and did a Docker build on the original (cloned/downloaded) multi-stage Dockerfile there and it worked!

I also tried doing a search+replace on the CRLF chars on copied/pasted code from an ebook, but that didn't work ultimately either.

@weseifert
Copy link

I had the same error on Mac OS Big Sur. I cloned the repo in the ~/go/src/ path (e.g. "git clone https://github.com/kubernetes-up-and-running/kuard.git") and ran docker build from the kuard directory it found the shell script and executed correctly.

@david-hatton
Copy link

david-hatton commented Jan 26, 2021

If you're running on Windows, ensure you're not converting the line endings to Windows. Easiest way to do this, which avoids all the post processing mentioned above is to configure it when you clone the repo, e.g.

git clone https://github.com/kubernetes-up-and-running/kuard.git --config core.autocrlf=input

See here: https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration

(Search for autocrlf)

@NRKirby
Copy link

NRKirby commented Feb 14, 2021

git clone https://github.com/kubernetes-up-and-running/kuard.git --config core.autocrlf=input

I can confirm that this works.

I can now run the docker build command without it erroring when it tries to run build.sh

@shan-wan
Copy link

shan-wan commented Mar 31, 2021

Yes, just append this line:

RUN git clone https://github.com/kubernetes-up-and-running/kuard .

after the WORKDIR line

# 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
# append this line
RUN git clone https://github.com/kubernetes-up-and-running/kuard .

# Copy all sources in
COPY . .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests