I'm trying to test the release version of my application inside a docker container on my local machine, and I keep getting the warning below when I spin up the container, and it refuses the requests:
Unable to bind to http://localhost:5000 on the IPv6 loopback interface: 'Cannot assign requested address'.
I've checked this post, and this is not the problem, and I haven't been able to get to the root cause of the problem. When I make requests, they get refused. The application works without a problem outside Docker. Below is my dotnet publish
command:
dotnet publish .\Sistema.Cadastro.Api\Sistema.Cadastro.Api.csproj -c Release --runtime linux-musl-x64 --interactive --no-self-contained
After it is published, I generate my container. Below is my Dockerfile
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
EXPOSE 5000
EXPOSE 5001
COPY System.Cadastro.Api/bin/Release/netcoreapp3.1/linux-musl-x64/publish/ /app
WORKDIR /app
ENTRYPOINT ["dotnet", "Sistema.Cadastro.Api.dll"]
After I've built the container, I use the docker-compose.yaml
below to start it:
version: '3'
services:
siefcadapi:
container_name: sistemacadapi
image: localdocker/sistema.cadastro.api:latest
ports:
- 5000:5000
- 5001:5001
environment:
- "ASPNETCORE_URLS=https://+:5001;http://+:5000"
Below is the log that is generated:
docker-compose -f .\.docker\docker-compose.yaml up
Recreating sistemacadapi ... done
Attaching to sistemacadapi
sistemacadapi | warn: Microsoft.AspNetCore.Server.Kestrel[0]
sistemacadapi | Unable to bind to http://localhost:5000 on the IPv6 loopback interface: 'Cannot assign requested address'.
sistemacadapi | info: Microsoft.Hosting.Lifetime[0]
sistemacadapi | Now listening on: http://localhost:5000
sistemacadapi | info: Microsoft.Hosting.Lifetime[0]
sistemacadapi | Application started. Press Ctrl+C to shut down.
sistemacadapi | info: Microsoft.Hosting.Lifetime[0]
sistemacadapi | Hosting environment: Production
sistemacadapi | info: Microsoft.Hosting.Lifetime[0]
sistemacadapi | Content root path: /app
I don't need to debug inside the container, or nothing of the sort. I just want to run and test my application so that I can push to Azure to run at the cloud.