Reputation: 161
I have created a docker image using jammy-chiseled-extra version. When I try to reach any endpoint I get HTTP 403. I tried http://localhost:5000/swagger
but I get only HTTP 403. Swagger works fine if I run application in debug also all endpoints are public.
Building image:
docker build --build-arg TARGETARCH=arm64 --no-cache -f Docker/ Dockerfile -t testimagecore1 .
Running container:
docker run -p 5000:5000 -d testimagecore1
# Use the chiseled container base image for .NET 8.0
FROM mcr.microsoft.com/dotnet/nightly/sdk:8.0-jammy-aot AS build
ARG TARGETARCH
WORKDIR /src
COPY . .
RUN dotnet publish --self-contained true -r linux-$TARGETARCH -o /app ./Demo.WebApi/Demo.WebApi.csproj
# final stage/image
FROM mcr.microsoft.com/dotnet/nightly/runtime-deps:8.0-jammy-chiseled-extra
WORKDIR /app
COPY --from=build /app .
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
USER $APP_UID
EXPOSE 5000
ENV ASPNETCORE_URLS=http://+:5000
ENV ASPNETCORE_HTTP_PORTS=5000
ENTRYPOINT ["./Demo.WebApi"]
Upvotes: 0
Views: 86
Reputation: 161
There were another MacOS service running on port 5000 that was return port 5000. After some trial and error I was getting empty responses, I was able to fix it by setting up this configuration ENV DOTNET_URLS=http://+:80
so allows dotnet core to listen do loopback ip and respond to requests from every IP.
Final version of docker file is
# Use the chiseled container base image for .NET 8.0
FROM mcr.microsoft.com/dotnet/nightly/sdk:8.0-jammy-aot AS build
ARG TARGETARCH
WORKDIR /src
COPY . .
RUN dotnet publish --self-contained true -r linux-$TARGETARCH -o /app ./Demo.WebApi/Demo.WebApi.csproj
# final stage/image
FROM mcr.microsoft.com/dotnet/nightly/runtime-deps:8.0-jammy-chiseled-extra
EXPOSE 80
ENV ASPNETCORE_HTTP_PORTS=80
ENV ASPNETCORE_URLS=http://+:80
ENV DOTNET_URLS=http://+:80
WORKDIR /app
COPY --from=build /app .
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
USER app
ENTRYPOINT ["./Demo.WebApi"]
Upvotes: 1