Reputation: 4198
I downloaded the ubuntu base image from the docker hub. Now I am trying to build a new image based on the ubuntu image. However, I want the default command for the ubuntu image to be "/bin/bash -c" instead of "/bin/sh" so as when I use RUN in my Dockerfile, it accesses bash instead of sh. Notice I am talking about the default command of the same image, not the image I am trying to build.
Upvotes: 19
Views: 22447
Reputation: 11
RUN chsh -s /bin/bash Add this in you docker file and the complete commands mentioned below this line will be executed with bash
Upvotes: 0
Reputation: 255
maybe this can help:
SHELL ["/bin/bash", "-c"]
Reference: https://github.com/moby/moby/issues/7281#issuecomment-389440503
Upvotes: 11
Reputation: 3919
I don't think there is a default command in the ubuntu
image. When you run
$ docker run ubuntu echo hi
hi
it runs ["/bin/echo", "hi"]
. You can verify that by running
$ docker run ubuntu set
2014/06/20 08:38:54 exec: "set": executable file not found in $PATH
set
is built-in command in shell, but docker tries to run it as an external one.
If you want to change the default shell from dash to bash, you can create an image with the fixed symlink. Here's a dockerfile:
FROM ubuntu
RUN ln -sf /bin/bash /bin/sh
[EDIT]
I just realized what you're talking about. I don't know if you can change the default for RUN
command, but you can explicitly use /bin/bash like this:
RUN /bin/bash -c ...
Upvotes: 7