How to define a specific shell to run RUN
scripts in a Dockerfile
FROM ubuntu
SHELL ["/bin/bash", "-c"]
# ...
How to dynamically load config from a .env
file during docker build
FROM ubuntu
SHELL ["/bin/bash", "-c"] # or, any other shell with a command to source env variables
# ...
RUN source .env && echo "foo: $FOO"
where
# .env
FOO=BAR
- Requires BASH as shell or any shell that has a command similar to
source
- Obviously, this makes only sense if you have a lot of configuration properties and don’t want to add an
ARG
directive for all of them; or, if you want to be able to load different configs depending on some other configuration property (like processor architecture).
How to always get output from a Dockerfile RUN directive
docker build \
--no-cache # prevents using cached layers
--progress=plain # show container output