I'm trying to set an environment variable with ENV instruction dynamically using $HOME variable (i think its a system environment variable).
But ENV is not able to access $HOME. Its blank. Although i'm able to echo $HOME.
FROM somebaseimage
....
....
USER 5051
RUN echo $HOME
# prints /home/myuser
ENV MY_JSON_FILEPATH="${HOME}/my_file.json"
RUN echo $MY_JSON_FILEPATH
# prints /my_file.json
I have tried "${HOME}/my_file.json", "$HOME/my_file.json"; both don't work.
What would be the best way to set such environment variable?
You should add the line ARG HOME
after the FROM ...
line and pass build option --build-arg or add build:args parameter in your docker-compose file.