Pass host environment variables to dockerfile

前端 未结 4 423
执笔经年
执笔经年 2020-12-28 20:23

How can I pass a host environment variable (like user and hostname) to a dockerfile?

For example, if my username is taha:

echo $USER
tah         


        
4条回答
  •  悲哀的现实
    2020-12-28 20:51

    When you start your docker container you can pass environment variables using the -e option like so:

    docker run -it  -e USER=$USER /bin/bash 
    

提交回复
热议问题