How to Dockerize

I have the following docker file
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
WORKDIR /app

# Copy everything
COPY . ./
# Restore as distinct layers
RUN dotnet restore
# Build and publish a release
RUN dotnet publish -c Release -o out

# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build-env /app/out .
EXPOSE 5000
ENTRYPOINT ["dotnet","ControllerApi.dll"]
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
WORKDIR /app

# Copy everything
COPY . ./
# Restore as distinct layers
RUN dotnet restore
# Build and publish a release
RUN dotnet publish -c Release -o out

# Build runtime image
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build-env /app/out .
EXPOSE 5000
ENTRYPOINT ["dotnet","ControllerApi.dll"]
pretty much copy paste from Microsoft https://learn.microsoft.com/de-de/dotnet/core/docker/build-container?tabs=linux&pivots=dotnet-8-0 but i encounter an error i dont have in any other environment about not finding serilog
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Serilog.Sinks.File, Version=5.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10'. The system cannot find the file specified.
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Serilog.Sinks.File, Version=5.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10'. The system cannot find the file specified.
I looked that my .csproj only reference serilog nuget package not the dll directly, and i'm not even using the file sink
Tutorial: Containerisieren einer .NET Core-App mit Docker - .NET
In diesem Tutorial erfahren Sie, wie Sie eine .NET-Anwendung mit Docker containerisieren können.
2 Replies
Pobiega
Pobiega8mo ago
Show your csproj?
Want results from more Discord servers?
Add your server