This guide explains how to build and run a Docker container for a published ASP.NET application using EvoPdf Chromium for Linux. The container is based on .NET 8 and includes all necessary system libraries and fonts required for EvoPdf to function correctly.
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_Linux.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 linux-x64 subdirectory inside the runtimes directory.
Place this ZIP file in the same directory as the Dockerfile before building the image.
The following Dockerfile installs the required Linux dependencies and the optional Microsoft Core Fonts for consistent text rendering. It then extracts your published application and configures the container to run it on port 27101.
This documentation uses mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim as the base image, which is built on Debian 12. Alternatively, you may use mcr.microsoft.com/dotnet/aspnet:8.0-jammy, which is based on Ubuntu 22.04 LTS, or another variant depending on your environment or specific requirements.
FROM mcr.microsoft.com/dotnet/aspnet:8.0-bookworm-slim
# Install EvoPdf dependencies and optionally the Microsoft Core Fonts
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libnss3 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libcups2 \
libgbm1 \
libxkbcommon0 \
libpango-1.0-0 \
libcairo2 \
libasound2 \
fontconfig \
wget \
unzip \
debconf-utils && \
echo 'ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true' | debconf-set-selections && \
wget -O /tmp/ttf-mscorefonts-installer_3.8_all.deb http://ftp.de.debian.org/debian/pool/contrib/m/msttcorefonts/ttf-mscorefonts-installer_3.8_all.deb && \
apt-get install -y /tmp/ttf-mscorefonts-installer_3.8_all.deb && \
fc-cache -f -v && \
rm -f /tmp/ttf-mscorefonts-installer_3.8_all.deb
# Set the working directory
WORKDIR /app
# Copy and unzip the published ASP.NET application
COPY published_EvoPdf_Chromium_AspNetDemo_Linux.zip /app/
RUN unzip /app/published_EvoPdf_Chromium_AspNetDemo_Linux.zip -d /app && \
rm /app/published_EvoPdf_Chromium_AspNetDemo_Linux.zip
# Ensure EvoPdf native loader is executable
RUN chmod +x /app/runtimes/linux-x64/native/evopdf_loadhtml
# Expose the port used by the app
EXPOSE 27101
# Set the ASP.NET Core application to listen on port 27101
ENV ASPNETCORE_URLS=http://+:27101
# Start the application
ENTRYPOINT ["dotnet", "EvoPdf_Chromium_AspNetDemo.dll"]
Once the Dockerfile and the published ZIP archive are placed in the same directory, you can build the Docker image and run it.
Use the following command to build the Docker image:
docker build -t evopdf-chromium-demo-image-linux .
Then, run the container:
docker run -d -p 27101:27101 --name evopdf-chromium-demo-app-linux evopdf-chromium-demo-image-linux
Open your browser and access the app at:
http://localhost:27101
You can also publish the Docker image to Azure Container Registry (ACR) and run the application directly from there, enabling easier deployment and integration within Azure-based environments.