I am writing a docker file in which at one specific step I am generating dynamic secret file which contains a lit of approx 20 env. variables, in below stand format:
To set environment variables in a Docker container, you can use the -e flag when running the docker run command. For example: $ docker run -e VAR_NAME1=value1 -e VAR_NAME2=value2 image_name
This will set the environment variables VAR_NAME1 and VAR_NAME2 to the values value1 and value2 , respectively, in the container.
Since every run instruction is a new container during docker build, you can’t set a variable like that and use it in an ENV instruction. You could only use that in the same instruction (same container and shell).
You could easily pass the variable as build arguments, but if those are actual secrets, like passwords, I wouldn’t store them in the image at all.