How can I pass Jenkins environment variables to docker container? How can I pass Jenkins environment variables to docker container? jenkins jenkins

How can I pass Jenkins environment variables to docker container?


you can set all your variables in .env file and give it to when docker going to run your container:

TBS_END_POINT=http://192.168.82.2:2020/QWErMONGO_HOST=172.17.0.3MONGO_PORT=27017REPLICA_SET=replicasetAPI_PORT=3001REDIS_PORT=4432NODE_ENV=development

then when you want to run you container say:

docker run --env-file .env MyImage


Did you try

docker run -e

https://docs.docker.com/engine/reference/run/#env-environment-variables

$ export today=Wednesday$ docker run -e "deep=purple" -e today --rm alpine envPATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binHOSTNAME=d2219b854598deep=purpletoday=WednesdayHOME=/root

or

$ docker run -d --name tst -e TESTME=YES busybox tail -f /dev/null55a3fe206588a8030365df30a670ca89a50c54816d044184d5870a4a76ce8199$ docker exec -it tst sh/ # echo $TESTMEYES/ #


Try to run docker-machine env in the Docker terminal to get a list of all the environment variables and their values.