Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save owenhsieh/f4e11f93fd8c37be455179b74e47ea91 to your computer and use it in GitHub Desktop.
Save owenhsieh/f4e11f93fd8c37be455179b74e47ea91 to your computer and use it in GitHub Desktop.
Shell script in docker - while editing in Windows environment

Note for myself, and for any begineer that might encounter this problem.

In short, always save linebreak as LF(Unix) rather than CRLF(Windows).

It would save you a lot of time.


I encounter this problem when I want to make a custom docker image that do a simple thing: Git Clone.

The Dockerfile looks like this:

FROM alpine:latest
RUN apk --no-cache add \
    git

VOLUME [ "/data" ]
ENTRYPOINT [ "/cloning.sh" ]

COPY cloning.sh /

It cannot be any simpler - but somehow docker put out an error:

standard_init_linux.go:185: exec user process caused "no such file or directory"

This is the cloning.sh:

#!/bin/sh
cd /data
git clone http://192.168.1.100:3000/owenhsieh/repo1.git
git clone http://192.168.1.100:3000/owenhsieh/repo2.git
git clone http://192.168.1.100:3000/owenhsieh/repo3.git
git clone http://192.168.1.100:3000/owenhsieh/repo4.git
git clone http://192.168.1.100:3000/owenhsieh/repo5.git

It doesn't make sense. So next I tryout install bash and remove #!/bin/sh incase it might somehow not having shell.

Then it first put out : No such file or directoryata then do git clone.

Still make no sense - then I notice directoryata.

So I check my linebreak.

CRLF

Yep.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment