Err_empty_response

Hi
I have a problem with access to swagger on host (windows 11)
I’m expecting address like localhost:7001/swagger
but errors occurs: ERR_EMPTY_RESPONSE
I have docker compose:

version: '3'
services:
  playground-server:
    restart: always
    build:
      context: ../../../marcom-infrastructure/.
      dockerfile: ../marcom-infrastructure/Marcom.Playground.WebAPI/Dockerfile
    #image: docker.io/marcommarekb/playground-server:1.0.0
    volumes:
      - playground-data:/usr/share/playground/data
    ports:
      - 7001:7001
    extra_hosts:
      - "host.docker.internal:host-gateway"
    depends_on:
      - elasticsearch
      - postgres
    networks:
      - marcom-core
volumes:
  playground-data:
    driver: local

network:

version: '3'
networks:
  marcom-core:
    name: marcom-core
    ipam:
      driver: default
      config:
        - subnet: 192.168.127.0/24

Dockerfile

#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY ["Marcom.Playground.WebAPI/Marcom.Playground.WebAPI.csproj", "Marcom.Playground.WebAPI/"]
RUN dotnet restore "Marcom.Playground.WebAPI/Marcom.Playground.WebAPI.csproj"
COPY . .
WORKDIR "/src/Marcom.Playground.WebAPI"
RUN dotnet build "Marcom.Playground.WebAPI.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Marcom.Playground.WebAPI.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Marcom.Playground.WebAPI.dll"]

Network settings for running container:

	"NetworkSettings": {
		"Bridge": "",
		"SandboxID": "215301fcd23d9e595dea19ea17a8e5e59ebf7694d7e88528d17cb7dfd301e2ba",
		"SandboxKey": "/var/run/docker/netns/215301fcd23d",
		"Ports": {
			"443/tcp": null,
			"7001/tcp": [
				{
					"HostIp": "0.0.0.0",
					"HostPort": "7001"
				}
			],
			"80/tcp": null
		},
		"HairpinMode": false,
		"LinkLocalIPv6Address": "",
		"LinkLocalIPv6PrefixLen": 0,
		"SecondaryIPAddresses": null,
		"SecondaryIPv6Addresses": null,
		"EndpointID": "",
		"Gateway": "",
		"GlobalIPv6Address": "",
		"GlobalIPv6PrefixLen": 0,
		"IPAddress": "",
		"IPPrefixLen": 0,
		"IPv6Gateway": "",
		"MacAddress": "",
		"Networks": {
			"marcom-core": {
				"IPAMConfig": null,
				"Links": null,
				"Aliases": [
					"marcom-playground-server-1",
					"playground-server",
					"4374543e02ca"
				],
				"MacAddress": "02:42:c0:a8:7f:06",
				"NetworkID": "3c7e55397dc781c9693679602bf995679e8a25078edda9437d364f2f7ed91f50",
				"EndpointID": "2e170bfa72a16d7493c25a4cab31f868db1bbbcf9bac8255ddaa2adc72316606",
				"Gateway": "192.168.127.1",
				"IPAddress": "192.168.127.6",
				"IPPrefixLen": 24,
				"IPv6Gateway": "",
				"GlobalIPv6Address": "",
				"GlobalIPv6PrefixLen": 0,
				"DriverOpts": null,
				"DNSNames": [
					"marcom-playground-server-1",
					"playground-server",
					"4374543e02ca"
				]
			}
		}
	}

Gerenal question is what’s wrong?
(In debug mode everything works)

Another general question: did you check the logs? empty response means the port is open and the application probably got the request but failed and sent an empty response. In this case the application could still log the error.

If the application works in debug mode, it is probably an application error, not a Docker-related issue. so it would require knowing the application. Or did you mean you ran Docker in debug mode?

1 Like

@rimelek thanks a lot for tip.
The difference between my debug and let’s say production version was in logs:
debug: Now listening on: http://[::]:7001
production: Now listening on: http://[::]:80

for debug my launchsettings.json:

    "Docker": {
      "commandName": "Docker",
      "dotnetRunMessages": true,
      "launchBrowser": true,
      "launchUrl": "http://0.0.0.0:7001/swagger/index.html",
      "applicationUrl": "http://0.0.0.0:7001",
      "publishAllPorts": true,
      "useSSL": false,
      "DockerfileRunArguments": "--network=marcom-core -p 7001:7001 -itd --name=marcom-playground-server-debug",
      "environmentVariables": {
        "ASPNETCORE_URLS": "http://+:7001",
        "ASPNETCORE_ENVIRONMENT": "development"
      }
    },

and I adjust my docker file with line:

ENV ASPNETCORE_URLS=http://+:7001

So now I’m able to stop container and run code in debug mode and also point port 7001.