title: passing docker environment variables to .net core
body: <p>I've followed this <a href="https://cmelendeztech.com/posts/2017/02/using-docker-env-vars-in-dotnet-core.html" rel="noreferrer">article</a> and the code on the <a href="https://github.com/christianhxc/hellodocker/blob/master/HelloDocker/Startup.cs" rel="noreferrer">github</a> doesn't compile, tutorial is outdated I think. (<code>Configuration = builder.Build();</code>) throws error. So how can I access env passed from docker?</p>
  
  <hr>
  
  <p><strong>docker-compose</strong></p>
  
  <pre><code>  myproj:
      image: mcr.microsoft.com/dotnet/core/sdk:2.2
      restart: on-failure
      working_dir: /MyProj
      command: bash -c "dotnet build MyProj.csproj &amp;&amp; dotnet bin/Debug/netcoreapp2.2/MyProj.dll"
      ports:
        - 5001:5001
        - 5000:5000
      volumes:
        - "./MyProj:/MyProj"
      environment:
        DATABASE_HOST: database
        DATABASE_PASSWORD: Password
  </code></pre>
  
  <hr>
  
  <p><strong>Startup.cs</strong></p>
  
  <pre><code>public Service()
  {
      Environment.GetEnvironmentVariable("DATABASE_PASSWORD"); // null
  }
  
  // This method gets called by the runtime. Use this method to add services to the container.
  // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
  public void ConfigureServices(IServiceCollection services)
  {
  }
  
  // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  {
      if (env.IsDevelopment())
      {
          app.UseDeveloperExceptionPage();
      }
  
      app.Run(async (context) =&gt;
      {
          context.Response.WriteAsync("Hello World!");
      });
  }
  </code></pre>