we are trying to pass windows environment variables as docker environment variable, does anyone have any idea how to achieve this?
This can be achieved easily on linx with below command
docker run -it --env-file <$(env | grep abc) ubuntu
But similar command on windows does not work
docker run -it --env-file=&set user ubuntu
docker run -it --env-file < $(&set user) ubuntu
Tried to achieve through batch command,
for /f usebackq %F in (`set user`) do docker run -it --rm -e %F ubuntu
But this iterates the env variables and pass only one env per run
Any help will be highly appreciated?
You can run the docker run command with environment names only, without the values and docker will pick the values set in the Windows environment variables when set/ available.
Example Instead of running docker run -p 8080:8080 -e FIRST_NAME='John' -e LAST_NAME='DOE'
, you first make sure those environment variables are set in your user/ system and run the same command in the format docker run -p 8080:8080 -e FIRST_NAME -e LAST_NAME
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.