Publish Winnovative PDF Chromium ASP.NET Demo to Docker on Windows

This guide explains how to build and run a Docker container for a published ASP.NET application using Winnovative PDF Chromium on Windows. The container is based on Windows Server Core LTSC 2022 and includes the .NET 8 ASP.NET Core runtime.

Publish Demo Application to a Folder

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_Winnovative_Chromium_AspNetDemo_Windows.zip. This archive should include the main DLL (e.g., Winnovative_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.

Dockerfile Configuration

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 27203.

 
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_Winnovative_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_Winnovative_Chromium_AspNetDemo_Windows.zip' -DestinationPath 'C:\\app'; \
    Remove-Item 'C:\\app\\published_Winnovative_Chromium_AspNetDemo_Windows.zip' -Force"

# Exposed application port
EXPOSE 27203

# Configure ASP.NET Core to listen on all interfaces and port 27203
ENV ASPNETCORE_URLS=http://+:27203

# Run the application
ENTRYPOINT ["C:\\dotnet\\dotnet.exe", "C:\\app\\Winnovative_Chromium_AspNetDemo.dll"]

Build and Run the Container

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 winnovative-chromium-demo-image-windows .

After the image is built, run the container and map port 27203 from the container to your host machine:

 
docker run -d -p 27203:27203 --name winnovative-chromium-demo-app-windows winnovative-chromium-demo-image-windows

Once the container is running, open your browser and navigate to:

 
http://localhost:27203

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.

See Also