Create docker Img from .NET Core (Console APP) that creates output file is not creating files with docker run

19 Views Asked by At

I created a console app that saves a file correctly when executing the application. I successfully created a Docker image from the main DLL. After running the image, the code executes properly, and I can see the console WriteLine outputs. However, the file is never created. Should I use *.exe instead of *.dll to create the Docker image? Below dockerfile

# Use the official .NET SDK image as a build environment
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
WORKDIR /app

# Copy the project file and restore dependencies
COPY *.csproj ./
RUN dotnet restore

# Copy the remaining source code and build the application
COPY . ./
RUN dotnet publish -c Release -o out

# Define the runtime environment
FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
COPY --from=build-env /app/out .

# Create a directory for logs and grant permissions
RUN mkdir /log && chmod 777 /log

# Set the entry point for the container
ENTRYPOINT ["dotnet", "myassembly.dll"]
0

There are 0 best solutions below