I'm starting to use Docker and I'm creating a Dockerfile. The image I use for the FROM statement has environment variables to configure it, but I don't know how to pass the variables to this image. To do this I just need to set the ENV in the Dockerfile?
Asked
Active
Viewed 2,272 times
1
-
Does this answer your question? [How do I set environment variables during the build in docker](https://stackoverflow.com/questions/39597925/how-do-i-set-environment-variables-during-the-build-in-docker) – Affes Salem Feb 12 '22 at 14:44
1 Answers
1
Yes set the env variable using ARG NAME_OF_ENV_VARIABLE
in dockerfile
and while building the docker image use --build-arg
Flag.
example:
docker build -t nameOfImage --build-arg NAME_OF_ENV_VARIABLE=ADD_YOUR_VALUE_TO_PASS .

Dashrath Mundkar
- 7,956
- 2
- 28
- 42