Docker Community Forums

Share and learn in the Docker community.

Source command in dockerfile

Hi,

I am working to build an image from a Docker file. In the normal way (in the ubuntu OS) for some of the software I needed to add something like in following to the bashrc file:

source <Path to FairRoot Installation>/bin/FairRootConfig.sh

How can I do the same thing when I am building a docker image?
I could not find in the ENV documentation for that.

Greets,
Maisam

Edit by a concerned bystander
If you want to get the effect of “use bash instead of sh throughout this entire Dockerfile”, without altering and possibly damaging* the OS inside the container, you can just tell Docker your intention. That is done like so:

SHELL ["/bin/bash", “-c”]

  • The possible damage is that many scripts in Linux (on a fresh Ubuntu install grep -rHInE ‘/bin/sh’ / returns over 2700 results) expect a fully POSIX shell at /bin/sh. The bash shell isn’t just POSIX plus extra builtins. There are builtins (and more) that behave entirely different than those in POSIX. I FULLY support avoiding POSIX (and the fallacy that any script that you didn’t test on another shell is going to work because you think you avoided basmisms) and just using bashism. But you do that with a proper shebang in your script. Not by pulling the POSIX shell out from under the entire OS. (Unless you have time to verify all 2700 plus scripts that come with Linux plus all those in any packages you install.)