title: IdentityServer4: Unable to obtain configuration from: '{servicename}.well-known/openid-configuration'. docker issue
body: <p>I have an <code>identityserver4</code> container (<code>identitymanagement:5003/localhost:5003</code>) 
  and a mvc app (<code>website.com:5000/localhost:5000</code>).</p>
  
  <p>Once both are running in docker and I try to go to <code>localhost:5000/home/login</code> (to be redirected to the <code>identityserver</code>) I get the error</p>
  
  <blockquote>
    <p>Unable to obtain configuration from: '<a href="https://identitymanagement:5003/.well-known/openid-configuration" rel="nofollow noreferrer">https://identitymanagement:5003/.well-known/openid-configuration</a>'.</p>
  </blockquote>
  
  <p>Here is all my different code parts</p>
  
  <p><strong>MVC: Login call</strong></p>
  
  <pre><code>public IActionResult Login()
  {
     return Challenge(new AuthenticationProperties
     {
         RedirectUri = "/Manage"
     });
  }
  </code></pre>
  
  <p><strong>MVC: Startup.cs</strong></p>
  
  <pre><code>public static IServiceCollection AddCustomAuthentication(this IServiceCollection services, IConfiguration configuration)
      {
  
          var callBackUrl = configuration.GetValue&lt;string&gt;("logoutCallbackUrl");
  
          services.AddAuthentication(options =&gt;
          {
              options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
              options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
          })
          .AddCookie(x=&gt;x.ExpireTimeSpan = TimeSpan.FromHours(2))
          .AddOpenIdConnect(options =&gt;
          {
              options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
              options.Authority = "https://identitymanagement:5003";
              options.SignedOutRedirectUri = callBackUrl.ToString();
              options.ClientId =  "website";
              options.ClientSecret = "secret";
              options.ResponseType = "code id_token";
              options.SaveTokens = true;
              options.GetClaimsFromUserInfoEndpoint = true;
              options.RequireHttpsMetadata = false;
              options.Scope.Add("openid");
              options.Scope.Add("profile");
  
  
          });
  
          return services;
      }
  }
  </code></pre>
  
  <p><strong>IdentityServer Startup.cs</strong></p>
  
  <pre><code>public class Startup
  {
      public Startup(IConfiguration configuration)
      {
          Configuration = configuration;
      }
  
      public IConfiguration Configuration { get; }
  
      // This method gets called by the runtime. Use this method to add services to the container.
      public void ConfigureServices(IServiceCollection services)
      {
          services.AddDbContext&lt;ApplicationDbContext&gt;(options =&gt;
              options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
  
  
          services.AddIdentity&lt;ApplicationUser, IdentityRole&gt;()
              .AddDefaultUI(UIFramework.Bootstrap4)
              .AddEntityFrameworkStores&lt;ApplicationDbContext&gt;()
              .AddDefaultTokenProviders();
  
  
          services.AddIdentityServer()
              .AddDeveloperSigningCredential()
              .AddInMemoryIdentityResources(Config.GetIdentityResources())
              .AddInMemoryApiResources(Config.GetApiResources())
              .AddInMemoryClients(Config.GetClients())
              .AddAspNetIdentity&lt;ApplicationUser&gt;();
  
      }
  
      // 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.UseDatabaseErrorPage();
          }
          else
          {
              app.UseExceptionHandler("/Error");
          }
  
          app.UseStaticFiles();
          app.UseIdentityServer();
          app.UseMvcWithDefaultRoute();
      }
  
  }
  </code></pre>
  
  <p><strong>Identityserver: Config.cs</strong></p>
  
  <pre><code>public class Config
  {
      public static IEnumerable&lt;ApiResource&gt; GetApiResources()
      {
          return new List&lt;ApiResource&gt;
          {
              new ApiResource("resourceApi", "API Application")
          };
      }
  
      // scopes define the resources in your system
      public static IEnumerable&lt;IdentityResource&gt; GetIdentityResources()
      {
          return new List&lt;IdentityResource&gt;
          {
              new IdentityResources.OpenId(),
              new IdentityResources.Profile(),
              new IdentityResources.Email()
          };
      }
  
      public static IEnumerable&lt;Client&gt; GetClients()
      {
          return new List&lt;Client&gt;
          {
  
  
              // OpenID Connect implicit flow client (MVC)
              new Client
              {
                  ClientId = "website",
                  ClientName = "Public Website",
                  AllowedGrantTypes = GrantTypes.Hybrid,
                  RequireConsent = false,
                  ClientSecrets =
                  {
                      new Secret("secret".Sha256())
                  },
  
                  RedirectUris = { "https://kryptoevents.com:5000/signin-oidc" },
                  PostLogoutRedirectUris = { "https://kryptoevents.com:5000/signout-callback-oidc" },
                  AllowedScopes =
                  {
                      IdentityServerConstants.StandardScopes.OpenId,
                      IdentityServerConstants.StandardScopes.Profile,
                      IdentityServerConstants.StandardScopes.Email,
  
                  }
              }
          };
      }
  
  }
  </code></pre>
  
  <p><strong>docker-compose.override.yml</strong></p>
  
  <pre><code>  identitymanagement:
      environment:
        - ASPNETCORE_ENVIRONMENT=Development
        - ASPNETCORE_URLS=https://+:443;http://+:80
        - ASPNETCORE_HTTPS_PORT=44378
      ports:
        - "60807:80"
        - "5003:443"
  
    website.com:
      environment:
        - ASPNETCORE_ENVIRONMENT=Development
        - ASPNETCORE_URLS=https://+:443;http://+:80
        - ASPNETCORE_HTTPS_PORT=44395
      ports:
        - "56530:80"
        - "5000:443"
  </code></pre>
  
  <p><strong>NOTE</strong>
  If i do not run the services in docker and just run them on IIS and instead of <code>options.Authority = "https://identitymanagement:5003"</code>; changing it to <code>"https://localhost:5003"</code> then everything works as expected.</p>
  
  <p>It seems that there is an issue inside docker and not being able to resolve <code>identitymanagment</code></p>
  
  <p>I have also tried using the IP address of the container instead of the <code>identitymanagement</code> and I get the same error.</p>
  
  <p>Do I need to do anything special when it comes to certificates when running inside docker?</p>