I run an ASP.NET Core service in a Docker container on MacOS.
Visual Studio for Mac v18.1.2 (build 2)
.NET Core SDK: 2.2.300
Here is the Dockerfile:
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build
WORKDIR /
COPY src/Services/Service.API/Service.API.csproj src/Services/Service.API/
RUN dotnet restore src/Services/Service.API/Service.API.csproj
COPY . .
WORKDIR /src/Services/Service.API
RUN dotnet build Service.API.csproj -c Release -o /app
FROM build AS publish
RUN dotnet publish Service.API.csproj -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "Service.API.dll"]
Here is how the docker-compose file for the service looks like:
service.api:
build:
context: .
dockerfile: src/Services/Service.API/Dockerfile
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://+:80;https://+:443
- ASPNETCORE_HTTPS_PORT=5254
- ASPNETCORE_Kestrel__Certificates__Default__Password=crypticpassword
- ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx
ports:
- "5204:80"
- "5254:443"
volumes:
- ${HOME}/.aspnet/https:/https/
The ports of the running Docker container looks good too:
0.0.0.0:5204->80/tcp, 0.0.0.0:5254->443/tcp
But when I try to call https://localhost:5254 it says site cannot be reached.
Also in the output I see following warning:
warn: Microsoft.AspNetCore.Server.Kestrel[0] Unable to bind to https://localhost:5001 on the IPv6 loopback interface: 'Cannot assign requested address'. Microsoft.AspNetCore.Server.Kestrel:Warning: Unable to bind to https://localhost:5001 on the IPv6 loopback interface: 'Cannot assign requested address'. Hosting environment: Development Content root path: /app Now listening on: https://localhost:5001
Why doesn't it take the urls set by the ASPNETCORE_URLS enivronment variable?
What else could I do for troubleshooting to find the problem?