# Running IronPDF on Linux: Setup Guide
IronPDF for Linux is about 280MB (including both IronPDF code and the entire Chrome browser). Docker images are around 500MB.
Chrome also requires some basic packages which vary based on your Linux distribution. Most Linux distributions have these packages installed already, as they are used by various applications and libraries on Linux.
However, if you're using a barebones distribution, you will need to install the Linux packages necessary to get Chrome running on Linux.
Note: In order to make debugging easier, you can set these:
```csharp
// Enable detailed debugging for IronPdf
IronPdf.Logging.Logger.EnableDebugging = true;
// Specify the log file path
IronPdf.Logging.Logger.LogFilePath = "Default.log";
// Set the logging mode to capture all log data
IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.All;
```
## How to Make a Smaller Docker Image
### 1. Installing Packages at Run-time
One way to reduce size is to run `apt-get` commands at runtime, rather than when building the docker image:
1. Remove `apt-get` commands from your Dockerfile.
2. Set `Installation.LinuxAndDockerDependenciesAutoConfig = true;` before initializing IronPDF or rendering a document.
3. Ensure your application is executed with sufficient permissions to run `apt-get` commands.
Note: Your first initialization will be slower as the `apt-get` commands must finish before rendering your first document, and this process will repeat every time you have to re-deploy the image.
Note: You should see console/log entries indicating successful package installs:
```shell
Executing command 'apt install -y libnss3' in '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native'
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
libnspr4
The following NEW packages will be installed:
libnspr4 libnss3
0 upgraded, 2 newly installed, 0 to remove and 9 not upgraded.
```
### 2. Use IronPdf.Slim
You can also choose to _only_ include IronPdf.dll and download the necessary files at runtime.
1. Remove IronPdf.Linux (and any other IronPDF) NuGet package(s) from your project and add IronPdf.Slim.
2. Set `Installation.AutomaticallyDownloadNativeBinaries = true;` before initializing IronPDF or rendering a document.
3. Ensure your Dockerfile grants read and write permissions to the entire working directory of your application (e.g., change `RUN chmod +rwx /app/runtimes/linux-x64/native/IronCefSubprocess` to `RUN chmod +rwx /app/`).
Note: Your first initialization will be slower as the NuGet package downloads and is extracted before rendering your first document, and this process will repeat every time you have to re-deploy the image.
Note: You should see console/log entries indicating a successful download and extraction:
```shell
Downloading NuGet package from 'https://www.nuget.org/api/v2/package/IronPdf.Native.Chrome.Linux/2023.1.11387'
Extracting package contents '/app/bin/Debug/netcoreapp3.1/IronPdf.Native.Chrome.Linux.2023.1.11387.nupkg/runtimes/linux-x64/native' to '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native'
Successfully deployed NuGet package 'IronPdf.Native.Chrome.Linux' to '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native'
Successfully located 'IronInterop' at '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native'
```
### 3. Conclusion
In summary, to reduce _initial container size:_
- Use the IronPdf.Slim NuGet package.
- Configure IronPDF:
```csharp
// Set installation options for Linux and Docker environments
Installation.LinuxAndDockerDependenciesAutoConfig = true;
Installation.AutomaticallyDownloadNativeBinaries = true;
```
- Ensure application directory is writable/executable:
```dockerfile
RUN chmod +rwx /app/
```
A very slim Docker image utilizing both points 1 and 2 should reduce the size from ~500MB to ~200MB.
If possible, you will see the best performance if you do NOT opt for a slim deployment.
Some containerized and cloud environments are _not persistent_ and thus may have to occasionally re-download dependencies or run the `apt-get` commands again, taking up to a couple of minutes!
However, we understand that some developers may be subject to strict size requirements for their deployments.
IronPDF for Linux is about 280MB (including both IronPDF code and the entire Chrome browser). Docker images are around 500MB.
Chrome also requires some basic packages which vary based on your Linux distribution. Most Linux distributions have these packages installed already, as they are used by various applications and libraries on Linux.
However, if you're using a barebones distribution, you will need to install the Linux packages necessary to get Chrome running on Linux.
Note: In order to make debugging easier, you can set these:
// Enable detailed debugging for IronPdfIronPdf.Logging.Logger.EnableDebugging = true;// Specify the log file pathIronPdf.Logging.Logger.LogFilePath = "Default.log";// Set the logging mode to capture all log dataIronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.All;
// Enable detailed debugging for IronPdf
IronPdf.Logging.Logger.EnableDebugging = true;
// Specify the log file path
IronPdf.Logging.Logger.LogFilePath = "Default.log";
// Set the logging mode to capture all log data
IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.All;
' Enable detailed debugging for IronPdfIronPdf.Logging.Logger.EnableDebugging = True' Specify the log file pathIronPdf.Logging.Logger.LogFilePath = "Default.log"' Set the logging mode to capture all log dataIronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.All
' Enable detailed debugging for IronPdf
IronPdf.Logging.Logger.EnableDebugging = True
' Specify the log file path
IronPdf.Logging.Logger.LogFilePath = "Default.log"
' Set the logging mode to capture all log data
IronPdf.Logging.Logger.LoggingMode = IronPdf.Logging.Logger.LoggingModes.All
How to Make a Smaller Docker Image
1. Installing Packages at Run-time
One way to reduce size is to run apt-get commands at runtime, rather than when building the docker image:
Remove apt-get commands from your Dockerfile.
Set Installation.LinuxAndDockerDependenciesAutoConfig = true; before initializing IronPDF or rendering a document.
Ensure your application is executed with sufficient permissions to run apt-get commands.
Note: Your first initialization will be slower as the apt-get commands must finish before rendering your first document, and this process will repeat every time you have to re-deploy the image.
Note: You should see console/log entries indicating successful package installs:
Executing command 'apt install -y libnss3' in '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native'Reading package lists...Building dependency tree...Reading state information...The following additional packages will be installed: libnspr4The following NEW packages will be installed: libnspr4 libnss30 upgraded, 2 newly installed, 0 to remove and 9 not upgraded.
Executing command 'apt install -y libnss3' in '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native'
Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
libnspr4
The following NEW packages will be installed:
libnspr4 libnss3
0 upgraded, 2 newly installed, 0 to remove and 9 not upgraded.
SHELL
2. Use IronPdf.Slim
You can also choose to only include IronPdf.dll and download the necessary files at runtime.
Remove IronPdf.Linux (and any other IronPDF) NuGet package(s) from your project and add IronPdf.Slim.
Set Installation.AutomaticallyDownloadNativeBinaries = true; before initializing IronPDF or rendering a document.
Ensure your Dockerfile grants read and write permissions to the entire working directory of your application (e.g., change RUN chmod +rwx /app/runtimes/linux-x64/native/IronCefSubprocess to RUN chmod +rwx /app/).
Note: Your first initialization will be slower as the NuGet package downloads and is extracted before rendering your first document, and this process will repeat every time you have to re-deploy the image.
Note: You should see console/log entries indicating a successful download and extraction:
Downloading NuGet package from 'https://www.nuget.org/api/v2/package/IronPdf.Native.Chrome.Linux/2023.1.11387'Extracting package contents '/app/bin/Debug/netcoreapp3.1/IronPdf.Native.Chrome.Linux.2023.1.11387.nupkg/runtimes/linux-x64/native' to '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native'Successfully deployed NuGet package 'IronPdf.Native.Chrome.Linux' to '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native'Successfully located 'IronInterop' at '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native'
Downloading NuGet package from 'https://www.nuget.org/api/v2/package/IronPdf.Native.Chrome.Linux/2023.1.11387'
Extracting package contents '/app/bin/Debug/netcoreapp3.1/IronPdf.Native.Chrome.Linux.2023.1.11387.nupkg/runtimes/linux-x64/native' to '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native'
Successfully deployed NuGet package 'IronPdf.Native.Chrome.Linux' to '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native'
Successfully located 'IronInterop' at '/app/bin/Debug/netcoreapp3.1/runtimes/linux-x64/native'
SHELL
3. Conclusion
In summary, to reduce initial container size:
Use the IronPdf.Slim NuGet package.
Configure IronPDF:
// Set installation options for Linux and Docker environmentsInstallation.LinuxAndDockerDependenciesAutoConfig = true;Installation.AutomaticallyDownloadNativeBinaries = true;
// Set installation options for Linux and Docker environments
Installation.LinuxAndDockerDependenciesAutoConfig = true;
Installation.AutomaticallyDownloadNativeBinaries = true;
' Set installation options for Linux and Docker environmentsInstallation.LinuxAndDockerDependenciesAutoConfig = TrueInstallation.AutomaticallyDownloadNativeBinaries = True
' Set installation options for Linux and Docker environments
Installation.LinuxAndDockerDependenciesAutoConfig = True
Installation.AutomaticallyDownloadNativeBinaries = True
Ensure application directory is writable/executable:
RUN chmod +rwx /app/
RUN chmod +rwx /app/
Text
A very slim Docker image utilizing both points 1 and 2 should reduce the size from ~500MB to ~200MB.
If possible, you will see the best performance if you do NOT opt for a slim deployment.
Some containerized and cloud environments are not persistent and thus may have to occasionally re-download dependencies or run the apt-get commands again, taking up to a couple of minutes!
However, we understand that some developers may be subject to strict size requirements for their deployments.
Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.