0

This is my docker compose file:

version: '3.4'

services:
  appone.api:
    image: ${DOCKER_REGISTRY-}apponeapi
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=https://+:443;http://+:80
      - ASPNETCORE_Kestrel__Certificates__Default__Password=
      - ASPNETCORE_Kestrel__Certificates__Default__Path=/https/AppOne.Api.pfx
    build:
      context: .
      dockerfile: AppOne.Api/Dockerfile
    networks: 
    - ${NETWORK}
    ports:
    - "59541:80"
    - "59542:443"
    volumes:
      - ~/.aspnet/https:/https:ro
      
networks:
  dev-network:
      name: ${NETWORK}

When I try to connect to https://localhost:59542/values via Postman, it will fail saying

Error: Client network socket disconnected before secure TLS connection was established

This is how I start it:

docker-compose -f docker-compose.yml up --force-recreate --build -d
docker image prune -f

Am I missing something? If I remove https://+443 and the port 443 reference, I am able to connect using http only via port 59541

JianYA
  • 2,750
  • 8
  • 60
  • 136
  • does (unencrypted) HTTP work? if you run `lsof` inside the container, does it show that something is listening on port 443? did you set up a certificate so that HTTPS can be served from that container? – root May 31 '22 at 03:23
  • Hi @root HTTP works if I remove the references to https in my docker compose and rebuild it. I am using the certificate set up using dev-certs. Is that correct? – JianYA May 31 '22 at 03:39
  • I don't know dev-certs (or Windows in general). But it looks like you're not alone: https://forums.docker.com/t/error-client-network-socket-disconnected-before-secure-tls-connection-was-established/125031 (unless that's you...) – root May 31 '22 at 03:45
  • Yeah that’s me. I managed to reach this stage and that is why I’m asking a new question. – JianYA May 31 '22 at 04:17
  • Have you enabled HTTPS in Docker, see https://stackoverflow.com/questions/50810165/run-docker-service-on-https – ralf htp May 31 '22 at 05:50
  • Hi @ralfhtp sorry I dont understand what does he mean by web server inside the docker application. Does he mean my .net core application? Or the Docker application? Both seem to be able to function on https because I have another similar project that can be accessed via https – JianYA May 31 '22 at 06:27
  • Does the Dockerfile of your image include `EXPOSE 443` ? See answer of marvelTracker in https://stackoverflow.com/questions/50810165/run-docker-service-on-https – ralf htp May 31 '22 at 08:04
  • Yes it exposes 80 and 443. – JianYA May 31 '22 at 08:07

0 Answers0