I'm trying to convert a service (IdentityServer 4 v2) that is a .Net Core 2.0 application to run on Docker for Windows. This is on a dev workstation only. I did the standard Visual Studio 2017 "Add Docker Support" to the existing Net Core 2.0 service. The service starts up fine, but fails due to these issues:
- The service is looking for a certificate installed on the local host machine. Running in docker it doesn't see this cert.
- The service is using DNS from the host machine etc/Hosts file to find our database server. The service running on Docker doesn't see the host machine DNS.
I attempted to set the network_mode in docker compose to "host" but that failed to build. What is the suggested way to set up such an environment?
The runtime is setup using docker compose, and the default compose and the configuration is very simple:
version: '3'
services:
identity.server:
image: identity.server
ports:
- "8100:8100"
build:
context: ./src/Identity.Server
dockerfile: Dockerfile
The referenced dockerfile:
FROM microsoft/dotnet:2.0-runtime
ARG source
WORKDIR /app
COPY ${source:-obj/Docker/publish} .
ENTRYPOINT ["dotnet", "Identity.Server.dll"]
I have read the following answer, but it doesn't appear to work inside of .Net itself: https://devops.stackexchange.com/questions/1501/configure-docker-to-use-ssl-for-a-private-registry-on-windows-10?newreg=0d065d6c37214be4bd1f02a45e1248ba
We are accessing the cert like this and it just comes back null. It is found if the service is run outside of Docker.
var cert = X509.LocalMachine.CertificateAuthority.Thumbprint
.Find(settings.CertificateThumbprint).FirstOrDefault();