VS2019 Docker ASP Core Environment Vars
Tip
If you are debugging with VS2017/9 and want to pass environment variables to your container then read this post, if you are looking for pictures of cats then sorry but leave a comment how you got here.
Step 1
Create a new text file, the name doesn’t matter, but I called mine Dockerfile.env.
![]()
![]()
Step 2
Add this file to your .csproj file.
![]()
Step 3
Not really a step but you can simply query your Environment variable in the usual fashion (Environment.GetEnvironmentVariable()).
![]()
Note:
Needless to say when you run in production you’ll need to pass the Environment variable according to Docker documentation which I don’t cover here.