How to bypass SSL and access cosmosDb emulator from docker container running a .net core app?

I’m attempting to connect to the cosmosDb emulator installed locally on my windows machine via a docker container running a .net core webapi project.

Unfortunately I get the following error as soon as the container starts…

Unhandled exception. System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.

The reason why appears to be detailed in this thread however the proposed solution at the end doesn’t seem to work for me.

I’m attempting to use CosmosDb with Entity Framework Core. My Startup.cs code looks like the following…

services.AddDbContext<EventCatalogCosmosDbContext>(options =>
    Configuration["CosmosDb:DatabaseName"].ToString(), cosmosClientOptions => new CosmosClientOptions()
        HttpClientFactory = () =>
            HttpMessageHandler httpMessageHandler = new HttpClientHandler()
                ServerCertificateCustomValidationCallback = (req, cert, chain, errors) => true
            return new HttpClient(httpMessageHandler);
        ConnectionMode = ConnectionMode.Gateway

After attempting to build my image and running it with the following command…

docker run -d -p 3000:80 -e "ConnectionStrings__CosmosConnection=AccountEndpoint=https://host.docker.internal:8081/;AccountKey=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==" --name myapp aspnetapp

I still get the error above.

Where am I going wrong?

Source: Docker Questions