Reputation: 2492
.Net core 5.0.103
docker version: 20.10.2, build 2291f61 (Ubuntu)
I create docker image + try to get environment variables from command line. So:
docker run -it --rm robust_tapir -e ADDRESS='127.0.0.1' -e Port='5000' -e Schema='http'
And result is:
[15:08:57 ERR] Hello World!
[15:08:57 ERR] Address:
[15:08:57 ERR] Port:
[15:08:57 ERR] Schema:
In my .net core console app:
Logger = CreateLogger();
Logger.Error("Hello World!");
await Task.Delay(5);
Address = Environment.GetEnvironmentVariable("ADDRESS");
Port = Environment.GetEnvironmentVariable("Port");
Schema = Environment.GetEnvironmentVariable("Schema");
#if DEBUG
Address = "127.0.0.1";
Port = "5000";
Schema = "http";
#endif
Logger.Error($"{nameof(Address)}:{Address}");
Logger.Error($"{nameof(Port)}:{Port}");
Logger.Error($"{nameof(Schema)}:{Schema}");
while (string.IsNullOrEmpty(Address))
{
await Task.Delay(1000);
}
So, what i do wrong? Wrong pass into container or wrong read it from .net core?
Upvotes: 0
Views: 663
Reputation: 36
Quotes goes around the entire env. argument:
docker run -it --rm robust_tapir -e "ADDRESS=127.0.0.1" -e "Port=5000" -e "Schema=http"
Upvotes: 1