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.
- Hardware: MacBook Pro (M1)
- Docker Version: Docker version 25.0.3, build 4debf411d1
- Container Runtime: colima version 0.7.5
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/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/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"]
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.
- Hardware: MacBook Pro (M1)
- Docker Version: Docker version 25.0.3, build 4debf411d1
- Container Runtime: colima version 0.7.5
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/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/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"]
Share
Improve this question
edited Nov 19, 2024 at 4:53
marc_s
757k184 gold badges1.4k silver badges1.5k bronze badges
asked Nov 18, 2024 at 23:17
MRBULL93MRBULL93
1611 gold badge4 silver badges12 bronze badges
1 Answer
Reset to default 1There 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/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/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"]