admin管理员组文章数量:1023744
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"]
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"]
本文标签: dockerAccess Deny on ASPNET Core Web API using jammychiseledextra imagesStack Overflow
版权声明:本文标题:docker - Access Deny on ASP.NET Core Web API using jammy-chiseled-extra images - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745589300a2157790.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论