I build my docker image using based on phusion/baseimage
The command I run to build my image is:
docker build --build-arg ENV_FILE=.env -t demo:latest .
my .env file looks like this:
VAR1=foo
VAR2=bar
and my dockerfile is like this
FROM phusion/baseimage:jammy-1.0.1
ARG VAR1
# I would like to print VAR1
RUN echo "my var1 equals to : $VAR1"
However I can't get VAR1 printed, it just shows an empty value
....
---> Running in 8f78bb5d59cc
my var1 equals to :
Any idea how I can read it when building the image?
You can do
You have to specify each variable though. I don't think there's a way to pass them all in as build arguments. .env files are meant for use at run-time.