Articles → DOCKER → Environmental Variable Inside The Docker Container

Environmental Variable Inside The Docker Container






Is The Environmental Created Inside The Container Or The Underlying Operating System?





Prerequisite





Create A Container With Environmental Variables




docker run -e VAR1=value1 -e VAR2=value2 --name environmentvariabledemo -it -d -p 85:80 ubuntu




  1. VAR1 and VAR2 and environmental variables
  2. environmentvariabledemo is the container name

Check The Value Of The Environment Variable




docker exec -it environmentvariabledemo sh
echo $VAR1



Output


Picture showing the value of the environment variable in the container
Click to Enlarge




Posted By  -  Karan Gupta
 
Posted On  -  Saturday, May 20, 2023

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250