# Set multiple Environment Variables

**URL:** <https://forums.docker.com/t/set-multiple-environment-variables/133585>\
**Category:** General\
**Tags:** docker\
**Created:** [December 30, 2022, 7:34am UTC](https://forums.docker.com/t/set-multiple-environment-variables/133585 "2022-12-30T07:34:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![amitarora1234](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/amitarora1234/32/32633_2.png) [@amitarora1234](https://forums.docker.com/u/amitarora1234)\
**Post date:** [December 30, 2022, 7:34am UTC](https://forums.docker.com/t/set-multiple-environment-variables/133585/1 "2022-12-30T07:34:49Z")

</div>

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:

export ABC=‘XXXXXXX’  
export DEF=‘XXXXXXX’  
export GHI=‘XXXXXXX’  
export JKL=‘XXXXXXX’  
…

I want to set all this variables values in env. variables.  
I ran below command but unable to set this values in ENV

RUN . ./secrets/env

The current option I am using now is as below:  
ENV ABC ${xxxx}

Is there option available to set all secret file values as Env. values.

---

<div class="post-metadata">

**Author:** ![ltimur](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/ltimur/32/38248_2.png) [@ltimur](https://forums.docker.com/u/ltimur)\
**Post date:** [December 30, 2022, 9:08am UTC](https://forums.docker.com/t/set-multiple-environment-variables/133585/2 "2022-12-30T09:08:44Z")

</div>

> [@amitarora1234](#):
>
> I want to set all this variables values in env. variables.

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.

---

<div class="post-metadata">

**Author:** ![rimelek](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/rimelek/32/41602_2.png) [@rimelek](https://forums.docker.com/u/rimelek)\
**Post date:** [December 31, 2022, 2:26pm UTC](https://forums.docker.com/t/set-multiple-environment-variables/133585/3 "2022-12-31T14:26:33Z")

</div>

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.
