.NET 8 Ausführen unter einem falschen Benutzer im Docker -ContainerC#

Ein Treffpunkt für C#-Programmierer
Guest
 .NET 8 Ausführen unter einem falschen Benutzer im Docker -Container

Post by Guest »

ein

Code: Select all

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

# Install procps package to get ps command
USER root
RUN apt-get update && apt-get install -y procps && rm -rf /var/lib/apt/lists/*

FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG configuration=Release
WORKDIR /src
COPY ["src/ExampleProject/ExampleProject.csproj", "src/ExampleProject/"]
RUN dotnet restore "src/ExampleProject/ExampleProject.csproj"
COPY . .
WORKDIR "/src/src/ExampleProject"
RUN dotnet build "ExampleProject.csproj" -c $configuration -o /app/build

FROM build AS publish
ARG configuration=Release
RUN dotnet publish "ExampleProject.csproj" -c $configuration -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
# Create a new folder in the application root folder and set permissions
RUN mkdir /app/Certificates && chown -R $APP_UID:$APP_UID /app/Certificates
RUN chown -R $APP_UID:$APP_UID /app
USER $APP_UID
ENTRYPOINT ["dotnet", "ExampleProject.dll"]
Trotz des Angebens von Benutzer $ app_uid wird der .NET -Prozess unter 10001
Top -Befehl im Pod ausgeführt: < Br />

Code: Select all

top - 08:32:15 up 9 days, 31 min,  0 user,  load average: 0.09, 0.58, 0.55
Tasks:   3 total,   1 running,   2 sleeping,   0 stopped,   0 zombie
%Cpu(s):  1.5 us,  1.0 sy,  0.0 ni, 97.4 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :  32093.8 total,    343.3 free,   4807.2 used,  27930.7 buff/cache
MiB Swap:      0.0 total,      0.0 free,      0.0 used.  27286.5 avail Mem

PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
1 10001     20   0 5006932  79232  59132 S   0.3   0.2   0:00.54 dotnet
28 10001     20   0    2576    900    804 S   0.0   0.0   0:00.00 sh
37 10001     20   0    8600   5056   2936 R   0.0   0.0   0:00.00 top
< /code>
Ich habe es mit App -Benutzer ausprobiert. Aus diesem Grund kann es nicht geschrieben werden, an /app/certificates
.
Einblicke oder Vorschläge zu dem, was dieses Problem verursachen könnte, wäre sehr geschätzt!

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post