kuard icon indicating copy to clipboard operation
kuard copied to clipboard

build.sh not found when doing docker build

Open zhoucengchao opened this issue 5 years ago • 33 comments

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!

zhoucengchao avatar Jan 07 '20 13:01 zhoucengchao

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

jastis77 avatar Jan 30 '20 17:01 jastis77

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 .

wbanguna avatar Feb 01 '20 20:02 wbanguna

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

arkfen avatar Feb 10 '20 09:02 arkfen

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

jbeda avatar Feb 12 '20 22:02 jbeda

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

funkybrown avatar Feb 14 '20 14:02 funkybrown

I'm also running into this.

❯ docker -v
Docker version 19.03.1, build 74b1e89

andyw8 avatar Feb 17 '20 00:02 andyw8

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.

andyw8 avatar Feb 17 '20 03:02 andyw8

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 avatar Feb 22 '20 20:02 jbeda

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

jbeda avatar Feb 22 '20 21:02 jbeda

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 avatar Feb 23 '20 13:02 arkfen

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?

arkfen avatar Feb 23 '20 13:02 arkfen

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

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

wiardvanrij avatar Feb 23 '20 17:02 wiardvanrij

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

image

arkfen avatar Feb 23 '20 18:02 arkfen

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.

jbeda avatar Feb 27 '20 14:02 jbeda

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.

Chike-O avatar Mar 14 '20 22:03 Chike-O

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.

harkanwals avatar Mar 20 '20 09:03 harkanwals

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

aryo-ps avatar Mar 23 '20 12:03 aryo-ps

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.

stanlearn777 avatar Mar 26 '20 13:03 stanlearn777

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

djfrmd avatar Mar 30 '20 15:03 djfrmd

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 avatar Apr 15 '20 15:04 os-learner

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

os-learner avatar Apr 15 '20 15:04 os-learner

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

djfrmd avatar Apr 16 '20 14:04 djfrmd

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

os-learner avatar Apr 16 '20 18:04 os-learner

You can also do this in VS Code: https://stackoverflow.com/questions/39525417/visual-studio-code-how-to-show-line-endings :)

isaacsgi avatar Apr 22 '20 20:04 isaacsgi

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!

xt94c4t9ce avatar Apr 28 '20 00:04 xt94c4t9ce

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

philippw avatar May 07 '20 10:05 philippw

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.

Niedman avatar Jun 14 '20 21:06 Niedman

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

arkfen avatar Aug 23 '20 18:08 arkfen

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.

simcikdt avatar Oct 25 '20 14:10 simcikdt

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.

weseifert avatar Jan 02 '21 03:01 weseifert