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

/bin/sh: 0: Illegal option - #114

Open
firekcc opened this issue Jun 16, 2019 · 5 comments
Open

/bin/sh: 0: Illegal option - #114

firekcc opened this issue Jun 16, 2019 · 5 comments

Comments

@firekcc
Copy link

firekcc commented Jun 16, 2019

i use the java8 dockerfile to build across the problem

the mvn-entrypoint.sh has error

/bin/sh: 0: Illegal option -

I hope you can take a look thanks

@carlossg
Copy link
Owner

what command do you use, what docker version, what sha of the docker image?

@mike-kotikov
Copy link

Hello, I faced the same annoying issue on Windows 10 =(
My docker version is 2.1.0.1
My colleague on Mac launched the same docker commands without any problems.
It seems like something is wrong with running sh scripts, but I really struggle to find what goes wrong.
Thanks for help in advance!

@charleech
Copy link

charleech commented Sep 4, 2019

I've faced the same issue when building this Maven docker at my Windows machine.

The root cause is the Windows use \r\n as a end-of-line, while the *nix use only \n. Then inside the docker there will be a ^M character at mvn-entrypoint.sh which leads us to the /bin/sh: 0: Illegal option - since the first line.

There are many ways to remove that ^M character as the following example: -

  • Upload the mvn-entrypoint.sh to the linux host and use the following command: -
    • sed -i -e 's/\r//g' /path/to/mvn-entrypoint.sh
    • Download it back to the Windows machine
  • Upload the mvn-entrypoint.sh to the linux host.
    • Use the well-known tools such as dos2unix to convert at the Linux machine.
    • Download it back to the Windows machine
  • Use the text editor such as Notepad++ at the Windows machine to convert
    • Go to menu Edit -> EOL Conversion -> Unix (LF)

@carlossg
Copy link
Owner

carlossg commented Sep 4, 2019

so it was only when you built it but not when you pulled it?

Thanks for the detailed description

@charleech
Copy link

charleech commented Sep 5, 2019

so it was only when you built it but not when you pulled it?

Yes. The official image published at the DockerHub works perfectly.


I'm quite sure that it's about the cloning this repository to the Windows machine which the Git client save as windows format, \r\n.

During building it locally on the Windows machine, there is no any issue. But when executing that customized image, e.g. docker run -it --rm my/custom:maven /bin/bash, this issue occurs since the mvn-entrypoint.sh will be executed first (via ENTRYPOINT ["/usr/local/bin/mvn-entrypoint.sh"]).

After removing the ^M from mvn-entrypoint.sh and rebuild, everything works like a charm.

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

4 participants