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?

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


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

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


Your Email Id  
Query/FeedbackCharacters remaining 250