The issue I was having was due to having the Kestrel configuration in appsettings.json as well as program.cs. For some reason, it was adding another Kestrel (instance?) to the one already configured in the program.cs code. The Kestrel config and https cert loaded in program.cs had already been working with the same Dockerfile and compose.yml. I only noticed it when the same error got triggered at App.run in program.cs while previously it triggered at the certificate loading code also in program.cs