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

why docker run command under /bin/sh????? #9861

Closed
lichuan opened this issue Dec 31, 2014 · 9 comments
Closed

why docker run command under /bin/sh????? #9861

lichuan opened this issue Dec 31, 2014 · 9 comments

Comments

@lichuan
Copy link

lichuan commented Dec 31, 2014

why docker run command with default /bin/sh, why? why? why? , I think /bin/bash is good than /bin/sh, if you run under /bin/sh, some command will produce error. please tell me why docker run command with /bin/sh instead of /bin/bash??????

@LK4D4
Copy link
Contributor

LK4D4 commented Dec 31, 2014

@lichuan command is image entity, not docker. So, all questions to image authors(I don't know what image do you use).
And in most cases /bin/sh is symlink to /bin/bash

@lichuan
Copy link
Author

lichuan commented Dec 31, 2014

for example when i write the below to dockerfile:

RUN echo -e "passwd\npasswd\n" | smbpasswd -a -s

when I build this dockerfile, error will happen.

@lichuan
Copy link
Author

lichuan commented Dec 31, 2014

if default shell is /bin/bash, there is no error. so why docker RUN command under /bin/sh????

@LK4D4
Copy link
Contributor

LK4D4 commented Dec 31, 2014

@lichuan try `RUN ["/bin/bash", "-c", ...]

@lichuan
Copy link
Author

lichuan commented Dec 31, 2014

@LK4D4

if docker RUN command under /bin/bash defaultly, the dockerfile can be very simple, RUN ["/bin/bash", "-c", ...] is ugly......

@phemmer
Copy link
Contributor

phemmer commented Dec 31, 2014

@lichuan sh is defined in the POSIX standard, while bash is not. Thus for highest compatibility, bash cannot be relied upon.

@SvenDowideit
Copy link
Contributor

As a specific example - the busybox image doesn't have bash - the boot2docker iso doesn't have bash either sh exists and is the default for a reason.

@unclejack
Copy link
Contributor

The builder documentation already states that /bin/sh is used for commands which look like RUN foo.

I'll close this issue since the only reason for keeping it open was to make the needed changes to the docs.

@odykyi
Copy link

odykyi commented Jan 25, 2018

add the first line to your *.sh file

#!/bin/sh

it works in docker

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

6 participants