[Public] How can I run IronPdf on Ubuntu 24.04 using Docker?
This article provides the dockerfile for running IronPdf on Ubuntu 24.04 within a Docker container. It includes a Dockerfile setup, required dependencies.
1. Create a Dockerfile
Use the following Dockerfile to set up your environment:
FROM mcr.microsoft.com/dotnet/runtime:8.0-noble AS base
USER root
WORKDIR /app
RUN apt update \
&& apt install -y sudo libxkbcommon-x11-0 libc6 libc6-dev libgtk2.0-0 libnss3 libatk-bridge2.0-0 libx11-xcb1 libxcb-dri3-0 libdrm-common libgbm1 libxrender1 libfontconfig1 libxshmfence1 libgdiplus libva-dev
RUN apt install -y sudo liboss4-salsa-asound2
RUN apt install -y sudo libasound2t64
# This stage is used to build the service project
FROM mcr.microsoft.com/dotnet/sdk:8.0-noble AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["ConsoleAppLinux/ConsoleAppLinux.csproj", "ConsoleAppLinux/"]
RUN dotnet restore "./ConsoleAppLinux/ConsoleAppLinux.csproj"
COPY . .
WORKDIR "/src/ConsoleAppLinux"
RUN dotnet build "./ConsoleAppLinux.csproj" -c $BUILD_CONFIGURATION -o /app/build
# This stage is used to publish the service project to be copied to the final stage
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./ConsoleAppLinux.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration)
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "ConsoleAppLinux.dll"]
2. Set Up Console App
Create a new console application targeting .NET 8. Install the IronPdf.Linux NuGet package using the NuGet Package Manager.
Conclusion
By following the steps outlined in this article, you can successfully set up IronPdf within a Docker container on Ubuntu 24.04, ensuring a stable and efficient environment for generating PDFs in .NET applications.