0

I would like to get environment variables from windows container which is ran by docker command but I could not get expected value of the variables.

In Dockerfile, I placed one of instructions likes

ENV Hello=World

In command prompt of windows, it runs a command of

docker build -t myapp .

and the image build successfully. Then run the image

docker run -e "Hello=Bye" myapp

In C#, I tried to get the environment variable Hello by

string debug = Environment.GetEnvironmentVariable("Hello");

and the debug would get World.
If the instruction ENV Hello=World is not placed in Dockerfile, the debug would get null.

I don't know what I should do in C# that getting debug with the value Bye which is my expected result. Thanks for the help.

S. Cheng
  • 13
  • 3

0 Answers0