I am using Jenkins pipeline to build and deploy a docker container.
What I want to do is to pass Jenkins environment variables to docker container.
See the screenshot.
I defined the environment variables on Jenkins.
I check the docker container environment variables using the following commands
- docker exec -it docker_id bash (get into the docker)
- printenv (print environment variables)
I want to see the Jenkins environment variables in docker container.
Is this possible? If so, please let me know the way to do it.
Thanks in advance!
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/QWEr
MONGO_HOST=172.17.0.3
MONGO_PORT=27017
REPLICA_SET=replicaset
API_PORT=3001
REDIS_PORT=4432
NODE_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 env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=d2219b854598
deep=purple
today=Wednesday
HOME=/root
or
$ docker run -d --name tst -e TESTME=YES busybox tail -f /dev/null
55a3fe206588a8030365df30a670ca89a50c54816d044184d5870a4a76ce8199
$ docker exec -it tst sh
/ # echo $TESTME
YES
/ #
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With