Adding IronPDF to an Existing Docker Container

This article was translated from English: Does it need improvement?
Translated
View the article in English

IronPDF for .NET Standard 现已完全支持 Docker,包括适用于 Linux 和 Windows 的 Azure Docker 容器。

是否希望将 IronPDF 部署为单独的 Docker 容器? 了解更多关于IronPDFEngine 教程指南的信息。

class="container-fluid">
class="row">
class="col-md-2"> Docker Logo
class="col-md-2"> Azure Logo
class="col-md-2"> Linux Logo
class="col-md-2"> AWS Logo
class="col-md-2"> Windows Logo

为什么在 Azure 上使用 Docker?

除了卓越的企业可扩展性,Azure 上的 Docker 容器还享有比普通 WebApps 更多的权限。这使得可以支持 SVG 字体的渲染,因为已启用对 GDI+ 图形的系统访问。

IronPDF 和 Linux 入门

如果您不熟悉 Docker 和 .NET,我们推荐这篇关于设置 Docker 调试和与 Visual Studio 项目的集成的优秀文章。

我们还强烈建议您阅读我们的IronPDF Linux 设置和兼容性指南

推荐的 Linux Docker 版本

我们推荐最新的64位 Linux 操作系统以便“轻松配置” IronPDF。

我们推荐使用 Microsoft 的官方 .NET Docker 镜像。 其他 Linux 发行版部分支持,但可能需要手动配置。 参见我们的“Linux 手动设置”指南。

IronPDF Linux Docker 安装

使用 Linux 优化的 NuGet 包

We recommend using the IronPdf.Linux NuGet package instead of the regular IronPdf package to save disk space and avoid assets being downloaded when you start your Docker instance. 不用担心,它在 Windows 或 macOS 的开发时仍然有效,只是针对 Linux 进行了优化。

Install-Package IronPdf.Linux

Another solution is to simply add IronPdf.Native.Chrome.Linux on top of the regular IronPdf NuGet package.

Install-Package IronPdf.Native.Chrome.Linux

避免自动安装依赖项

许多用户报告称,设置LinuxAndDockerDependenciesAutoConfig为 false 时,Linux & Docker 的结果更好。 这是因为先决条件已经通过 Docker 文件中的apt-get样式包管理器安装。

// Disable automatic configuration of Linux and Docker dependencies
IronPdf.Installation.LinuxAndDockerDependenciesAutoConfig = false;
// Disable automatic configuration of Linux and Docker dependencies
IronPdf.Installation.LinuxAndDockerDependenciesAutoConfig = false;
' Disable automatic configuration of Linux and Docker dependencies
IronPdf.Installation.LinuxAndDockerDependenciesAutoConfig = False
$vbLabelText   $csharpLabel

禁用 GPU 加速

Linux Docker 容器通常无法访问 GPU。 默认情况下禁用 GPU 加速。 如果您已经启用ChromeGpuModes.Enabled,我们强烈建议您在 Docker 部署时禁用它:

// Disable GPU acceleration for Docker environments
IronPdf.Installation.ChromeGpuMode = IronPdf.Engines.Chrome.ChromeGpuModes.Disabled;
// Disable GPU acceleration for Docker environments
IronPdf.Installation.ChromeGpuMode = IronPdf.Engines.Chrome.ChromeGpuModes.Disabled;
' Disable GPU acceleration for Docker environments
IronPdf.Installation.ChromeGpuMode = IronPdf.Engines.Chrome.ChromeGpuModes.Disabled
$vbLabelText   $csharpLabel

Ubuntu Linux Docker 文件

class="container-fluid">
class="row">
class="col-md-2"> Docker Logo
class="col-md-2"> Ubuntu Logo

Ubuntu 22 和 .NET 8

Ubuntu 22 with .NET 7

Ubuntu 20 with .NET 6

Ubuntu 20 with .NET 5

Ubuntu 20 with .NET 3.1 LTS

Ubuntu 18 with .NET 3.1 LTS

Debian Linux Docker Files

Docker Logo
Debian Logo

Debian 12 with .NET 8

Debian 11 with .NET 7

Debian 11 with .NET 6

Debian 11 with .NET 5

Debian 11 with .NET 3.1 LTS

Debian 10 with .NET 5

Debian 10 with .NET 3.1 LTS

Alpine Linux Docker Files

Running IronPDF on Alpine Linux is not supported. We wish we could but we can't. Frankly, we like Alpine and hope this project continues and grows. As of 2023, Alpine still uses outdated "musl" C language libraries that do not allow chromium developers to fully support this OS yet.

Using Alpine Docker with IronPdfEngine in .NET 6

IronPDF provides a container image containing all IronPDF functionalities. This enables projects running on Alpine to access IronPD functionalities by connecting to the IronPdfEngine container.

Step 1: Pull and Run IronPDF Engine Docker Image

Execute the following commands in your terminal to pull and run the IronPDF Engine Docker image:

# Pull the IronPDF Engine Docker Image
docker pull ironsoftwareofficial/ironpdfengine
# Pull the IronPDF Engine Docker Image
docker pull ironsoftwareofficial/ironpdfengine
SHELL
# Run the IronPDF Engine Docker container
docker run -d -p 33350:33350 ironsoftwareofficial/ironpdfengine
# Run the IronPDF Engine Docker container
docker run -d -p 33350:33350 ironsoftwareofficial/ironpdfengine
SHELL

Step 2: Set Up Console App

Create a new console application targeting .NET 6. Install the IronPdf.Slim NuGet package using the NuGet Package Manager.

Windows Docker File

Docker Logo
Windows Logo

Windows Docker Containers are becoming increasingly popular on Azure, as they offer higher levels of performance and scalability and give developers more permissions to configure instances.

IronPDF will actually perform more attractive text rendering within a Docker container (Windows or Linux) on Azure due to higher levels of access to graphics library and the virtual graphics card.

The article 'Visual Studio Container Tools for Docker' is a really great get-started guide.

This is an example Windows container Dockerfile for .NET Core 3.1

Windows Server 2019 .NET 6.0

Pre-configured Windows containers include all the necessary dependencies for running IronPDF.

请注意Note that these containers are not intended for BUILDING .NET applications, but rather for RUNNING them.

Visit the Docker repository to explore additional pre-configured images for running IronPDF.

常见问题解答

如何将 .NET 库集成到 Docker 容器中生成 PDF?

您可以通过使用 Microsoft 的官方 Docker 镜像和 IronPdf.Linux NuGet 包(用于 Linux)或预配置的 Windows Docker 容器(用于 Windows 环境)将 IronPDF 这个 .NET PDF 生成库集成到 Docker 容器中。

在 Azure 上使用 Docker 容器进行 PDF 操作有什么好处?

在 Azure 上使用 Docker 容器进行 PDF 操作提供了增强的企业级可扩展性和比常规 WebApps 更多的权限。此设置非常适合启用高级功能,例如通过 GDI+ 图形访问渲染 SVG 字体。

哪些 Linux 发行版最适合在 Docker 中运行 .NET PDF 库?

最适合在 Docker 中运行 IronPDF 的 Linux 发行版包括 Ubuntu 18/20/22、Debian 10/11、CentOS 8 和 Amazon AWS Linux 2,因为它们提供简单的配置和兼容性。

如何优化 Linux Docker 容器中 .NET PDF 库的性能?

要优化性能,请使用 IronPdf.Linux 包,禁用自动依赖安装,并通过配置 IronPdf.Installation.ChromeGpuModeIronPdf.Engines.Chrome.ChromeGpuModes.Disabled 关闭 GPU 加速。

IronPDF 可以在 Docker 容器内的 Alpine Linux 上运行吗?

由于 'musl' 库不兼容,IronPDF 不原生支持 Alpine Linux。要在 Alpine Linux 上使用 IronPDF,可以通过 IronPdfEngine Docker 容器运行它。

使用预配置的 Docker 容器运行 .NET 库的目的是什么?

预配置的 Docker 容器提供了运行 IronPDF 所需的所有依赖,以确保高性能和可扩展性,特别是在如 Azure 这样的平台上部署时。

如何为 .NET 应用程序在 Docker 中配置 .NET PDF 库?

您可以通过将 IronPDF 与 Linux 和 Windows Docker 容器集成,实现微服务架构中的强大 PDF 功能,来为 .NET 应用程序配置 IronPDF。

部署 .NET 库在 Docker 中的推荐设置步骤是什么?

推荐步骤包括使用诸如 IronPdf.Linux 的 Linux 优化包,禁用自动依赖安装,以及在 Docker 环境的运行时预初始化 IronPDF 以防止延迟。

我如何在运行 .NET 6.0 的 Windows Server 2019 Docker 容器中设置 .NET PDF 库?

通过使用包含所有必要依赖和配置来运行 IronPDF 的预配置 Dockerfile,在 Windows Server 2019 Docker 容器中设置 .NET PDF 库与 .NET 6.0。

为什么在 Docker 设置中对于 .NET 库要禁用 GPU 加速?

禁用 Docker 中 IronPDF 的 GPU 加速可以通过避免在资源有限的 GPU 环境中可能发生的图形相关问题来实现更流畅的部署和性能。

Curtis Chau
技术作家

Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。

除了开发之外,Curtis 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。

准备开始了吗?
Nuget 下载 16,154,058 | 版本: 2025.11 刚刚发布