This guide explains how to build and run a Docker container for a published ASP.NET application using EvoPdf Chromium on Windows. The container is based on Windows Server Core LTSC 2022 and includes the .NET 8 ASP.NET Core runtime.
Before proceeding, ensure that your ASP.NET application is published to a folder using Visual Studio, with the target runtime set to Portable. Compress the published folder into a ZIP archive. For our demo application, the archive is named published_EvoPdf_Chromium_AspNetDemo_Windows.zip. This archive should include the main DLL (e.g., EvoPdf_Chromium_AspNetDemo.dll) and the runtimes directory at the root level. To reduce the ZIP file size, you may retain only the win-x64 subdirectory inside the runtimes directory.
Place this ZIP file in the same directory as the Dockerfile before building the image.
The Dockerfile below installs the .NET 8.0 ASP.NET Core Runtime manually from a ZIP archive, extracts your published application and configures the container to run it on port 27102.
# Use Windows Server Core LTSC 2022 as base image
FROM mcr.microsoft.com/windows/server:ltsc2022
# Install .NET 8.0.16 ASP.NET Core Runtime from ZIP
RUN C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "Invoke-WebRequest -Uri 'https://builds.dotnet.microsoft.com/dotnet/aspnetcore/Runtime/8.0.16/aspnetcore-runtime-8.0.16-win-x64.zip' -OutFile 'C:\\dotnet.zip'; \
Expand-Archive -Path 'C:\\dotnet.zip' -DestinationPath 'C:\\dotnet'; \
Remove-Item 'C:\\dotnet.zip' -Force"
# Set .NET runtime root
ENV DOTNET_ROOT=C:\dotnet
# Set working directory for the app
WORKDIR C:/app
# Copy the published ASP.NET Core app archive into container
COPY published_EvoPdf_Chromium_AspNetDemo_Windows.zip .
# Extract the application and remove the ZIP
RUN C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command "Expand-Archive -Path 'C:\\app\\published_EvoPdf_Chromium_AspNetDemo_Windows.zip' -DestinationPath 'C:\\app'; \
Remove-Item 'C:\\app\\published_EvoPdf_Chromium_AspNetDemo_Windows.zip' -Force"
# Exposed application port
EXPOSE 27102
# Configure ASP.NET Core to listen on all interfaces and port 27102
ENV ASPNETCORE_URLS=http://+:27102
# Run the application
ENTRYPOINT ["C:\\dotnet\\dotnet.exe", "C:\\app\\EvoPdf_Chromium_AspNetDemo.dll"]
Once the Dockerfile and the published ZIP archive are placed in the same directory, you can build and run the container using the following commands.
Open PowerShell or Command Prompt with Docker configured for Windows containers and build the image using:
docker build -t evopdf-chromium-demo-image-windows .
After the image is built, run the container and map port 27102 from the container to your host machine:
docker run -d -p 27102:27102 --name evopdf-chromium-demo-app-windows evopdf-chromium-demo-image-windows
Once the container is running, open your browser and navigate to:
http://localhost:27102
You can also publish the Docker image to Azure Container Registry (ACR) and run the application from there, enabling easier deployment and integration within Azure-based environments.