C#C
C#2y ago
SOMUCHDOG

✅ .Net 8 WebApi not responding from Docker container

I am running a default .Net 8 webapi project that I created via the dotnet CLI
dotnet new webapi -n dotnetapi



The project builds and runs locally, I am able to get a response.

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

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
WORKDIR /src
COPY . .
RUN dotnet restore
RUN dotnet build -c Release -o /app/build

FROM build AS publish
RUN dotnet publish -c Release -o /app/publish

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


I build the image and run it

docker run -p 5154:80 dotnet-api


Cannot get a response from the api
curl http://localhost:5154/weatherforecast


Any help appreciated!
Was this page helpful?