Field Note

Field notes of March, 27th 2024

docker dockerfile run build-arg output
Posted on Wednesday, March the 27th 2024
1 min read

Specifying a shell to run RUN scripts in a Dockerfile

FROM ubuntu
SHELL ["/bin/bash", "-c"]
# ...

Dynamically loading 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).

Verbose output from Dockerfile RUN

docker build \
  --no-cache # prevents using cached layers
  --progress=plain # show container output

Running multiple container scanning jobs via the GitLab container_scanning template

friedrichkurz.me

© 2025 Friedrich Kurz

Privacy Policy