Run IronPDF as a Remote Container

The IronPdfEngine is a standalone service which can handle the creating, writing, editing, and reading of PDFs. IronPDF Docker is ready to run docker services with compatible versions of IronPDF (v2023.2.x and above). This will help developers eradicate deployment issues that they may be experiencing with IronPDF.

Why running IronPDF as its own container is a good idea

IronPDF requires both Chrome and Pdfium binaries in order to operate which are huge in file size (hundreds of MBs). It also requires several dependencies to be installed on the machine.

By using this method, your client will only take up a fraction of the size (in MB).

Avoid Deployment Issues

It can be difficult to configure the environment/container to properly include all dependencies. Using the IronPDF Docker container means that IronPDF comes pre-installed and guaranteed to work, avoiding all deployment and dependency headaches.

Versions

The IronPDF Docker tag is based on the version of IronPdfEngine itself. It is not the same version as the IronPDF product.

Each IronPDF version will have its own associated IronPdfEngine version. The version number must match the IronPDF Docker version.

For example: For IronPDF for Java version 2023.2.1 requires IronPdfEngine version 2023.2.1. You cannot use mistmatched IronPdfEngine and IronPDF versions.

How to use IronPDF Docker

Step 1 - Install IronPDF

Add the IronPdf.Slim Nuget package to your project.

https://www.nuget.org/packages/IronPdf.Slim/

| More info: https://ironpdf.com/docs/

Note: IronPdf, IronPdf.Linux and IronPdf.MacOs Packages all contain IronPdf.Slim.

To reduce your application size, we recommend installing just IronPdf.Slim. Package IronPdf.Native.Chrome.xxx is no longer used, so you can remove it from your project.

Step 2 - Determine Required Container Version

By default, the IronPDF for Docker version will match the current version of IronPDF on NuGet.

You may additionally confirm by checking the version manually:

:path=/static-assets/pdf/content-code-examples/how-to/ironpdfengine-docker-version.cs
string ironPdfEngineVersion = IronPdf.Installation.IronPdfEngineVersion;
Dim ironPdfEngineVersion As String = IronPdf.Installation.IronPdfEngineVersion
VB   C#

Step 3 - Setup IronPDF for Docker Container

Step 3.i - Without Docker Compose

Run the docker container using the version from the previous step

For example for IronPDF for Docker version e.g. 2023.2.1:

docker network create -d bridge --attachable --subnet=172.19.0.0/16 --gateway=172.19.0.1 ironpdf-network

docker run -d -e IRONPDF_ENGINE_LICENSE_KEY=MY_LICENSE_KEY --network=ironpdf-network --ip=172.19.0.2 --name=ironpdfengine --hostname=ironpdfengine -p 33350:33350 ironsoftwareofficial/ironpdfengine:2023.2.1

| Port 33350 is the default internal port of IronPdfEngine

Now IronPDF for Docker is up and running!

Step 3.ii - With Docker Compose

Set up your Docker Compose file using the following template:

version: "3.3"

services:
  ironpdfengine:
    container_name: ironpdfengine
    image: ironsoftwareofficial/ironpdfengine:latest
    networks:
      ironpdf-network:
        ipv4_address: 172.19.0.2
  myconsoleapp:
    container_name: myconsoleapp
    build:
      # enter YOUR project directory path here
      context: ./MyConsoleApp/
      # enter YOUR dockerfile name here, relative to project directory
      dockerfile: Dockerfile
    networks:
      ironpdf-network:
        ipv4_address: 172.19.0.3
    depends_on:
      ironpdfengine:
        condition: service_started

networks:
  ironpdf-network:
    driver: bridge
    ipam:
      config:
        - subnet: 172.19.0.0/16
          gateway: 172.19.0.1
YAML

And then run your docker compose command like the following:

docker compose up --detach --force-recreate --remove-orphans --timestamps

Step 4 - Configure your IronPDF Client

Add this line:

:path=/static-assets/pdf/content-code-examples/how-to/ironpdfengine-docker-configure.cs
using IronPdf.GrpcLayer;

var config = new IronPdfConnectionConfiguration();
config.ConnectionType = IronPdfConnectionType.Docker;
IronPdf.Installation.ConnectToIronPdfHost(config);
Imports IronPdf.GrpcLayer

Private config = New IronPdfConnectionConfiguration()
config.ConnectionType = IronPdfConnectionType.Docker
IronPdf.Installation.ConnectToIronPdfHost(config)
VB   C#

Step 5 - Enjoy

Run your IronPDF code, your app now talks to the IronPdfEngine in Docker!

Client Test Code

:path=/static-assets/pdf/content-code-examples/how-to/ironpdfengine-docker-use.cs
using IronPdf;
using IronPdf.GrpcLayer;

var config = new IronPdfConnectionConfiguration();
config.ConnectionType = IronPdfConnectionType.Docker;
IronPdf.Installation.ConnectToIronPdfHost(config);

ChromePdfRenderer renderer = new ChromePdfRenderer();
PdfDocument pdf = renderer.RenderHtmlAsPdf("<h1>Hello IronPDF Docker!<h1>");
pdf.SaveAs("ironpdf.pdf");
Imports IronPdf
Imports IronPdf.GrpcLayer

Private config = New IronPdfConnectionConfiguration()
config.ConnectionType = IronPdfConnectionType.Docker
IronPdf.Installation.ConnectToIronPdfHost(config)

Dim renderer As New ChromePdfRenderer()
Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf("<h1>Hello IronPDF Docker!<h1>")
pdf.SaveAs("ironpdf.pdf")
VB   C#