IRONSOFTWAREHOME

在 Docker 容器中設定 IronOCR

Curtis Chau
Curtis Chau
Updated: 2026年6月29日

在 C# 中對影像或 PDF 檔案進行 OCR 辨識嗎?

IronOCR 現在完全支援 Docker,包括適用於 Linux 和 Windows 的 Azure Docker 容器。

Docker Linux AWS Windows

為什麼要使用 Docker?

Docker 使開發人員能夠輕鬆地將任何應用程式打包、交付和運行為輕量級、可移植、自包含的容器,該容器幾乎可以在任何地方運行。

IronOCR 和 Linux 入門

如果您是第一次接觸 Docker 與 .NET,我們推薦您閱讀這篇關於設定 Docker 偵錯以及如何將其與 Visual Studio 專案整合的優秀文章。 https://docs.microsoft.com/en-us/visualstudio/containers/edit-and-refresh?view=vs-2019

我們也強烈建議您閱讀我們的IronOCR Linux設定與相容性指南

推薦的 Linux Docker 發行版

我們推薦使用以下最新的 64 位元 Linux 作業系統,以便"輕鬆配置"IronPDF。

  • Ubuntu 20
  • Ubuntu 18
  • Debian 11
  • Debian 10 [目前是 Microsoft Azure 的預設 Linux 發行版]

我們建議使用微軟官方的 Docker 映像。 其他 Linux 發行版部分支持,但可能需要使用 apt-get 手動配置。 請查閱我們的"Linux手動設定"指南。

本文件中包含適用於 Ubuntu 和 Debian 的 Docker 檔案:

IronOCR Linux Docker 安裝要點

使用我們的 NuGet 套件

我們建議使用IronOCR NuGet包。 它在 Windows、macOS 和 Linux 系統上進行開發時均可正常運作。

PM > Install-Package IronOcr

Ubuntu Linux Dockerfiles

Docker Linux Ubuntu

Ubuntu 20 和 .NET 5

# Use the base runtime image for Ubuntu 20 with .NET runtime
FROM mcr.microsoft.com/dotnet/runtime:5.0-focal AS base
WORKDIR /app

# Install necessary packages
RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev

# Use the base development image for Ubuntu 20 with .NET SDK
FROM mcr.microsoft.com/dotnet/sdk:5.0-focal AS build
WORKDIR /src

# Restore NuGet packages
COPY ["Example/Example.csproj", "Example/"]
RUN dotnet restore "Example/Example.csproj"

# Build the project
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build

# Publish the project
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish

# Run the application
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]
Text

Ubuntu 20 搭載 .NET 3.1 LTS

# Use the base runtime image for Ubuntu 20 with .NET runtime
FROM mcr.microsoft.com/dotnet/runtime:3.1-focal AS base
WORKDIR /app

# Install necessary packages
RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev

# Use the base development image for Ubuntu 20 with .NET SDK
FROM mcr.microsoft.com/dotnet/sdk:3.1-focal AS build
WORKDIR /src

# Restore NuGet packages
COPY ["Example/Example.csproj", "Example/"]
RUN dotnet restore "Example/Example.csproj"

# Build the project
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build

# Publish the project
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish

# Run the application
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]
Text

Ubuntu 18 搭載 .NET 3.1 LTS

# Use the base runtime image for Ubuntu 18 with .NET runtime
FROM mcr.microsoft.com/dotnet/runtime:3.1-bionic AS base
WORKDIR /app

# Install necessary packages
RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev

# Use the base development image for Ubuntu 18 with .NET SDK
FROM mcr.microsoft.com/dotnet/sdk:3.1-bionic AS build
WORKDIR /src

# Restore NuGet packages
COPY ["Example/Example.csproj", "Example/"]
RUN dotnet restore "Example/Example.csproj"

# Build the project
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build

# Publish the project
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish

# Run the application
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]
Text

Debian Linux Dockerfiles

Docker Linux Debian

Debian 11 及 .NET 5

# Use the base runtime image for Debian 10 with .NET runtime
FROM mcr.microsoft.com/dotnet/aspnet:5.0-bullseye-slim AS base
WORKDIR /app

# Install necessary packages
RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev

# Use the base development image for Debian 10 with .NET SDK
FROM mcr.microsoft.com/dotnet/sdk:5.0-bullseye-slim AS build
WORKDIR /src

# Restore NuGet packages
COPY ["Example/Example.csproj", "Example/"]
RUN dotnet restore "Example/Example.csproj"

# Build the project
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build

# Publish the project
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish

# Run the application
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]
Text

Debian 11 及 .NET 3.1 LTS

# Use the base runtime image for Debian 10 with .NET runtime
FROM mcr.microsoft.com/dotnet/aspnet:3.1-bullseye-slim AS base
WORKDIR /app

# Install necessary packages
RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev

# Use the base development image for Debian 10 with .NET SDK
FROM mcr.microsoft.com/dotnet/sdk:3.1-bullseye-slim AS build
WORKDIR /src

# Restore NuGet packages
COPY ["Example/Example.csproj", "Example/"]
RUN dotnet restore "Example/Example.csproj"

# Build the project
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build

# Publish the project
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish

# Run the application
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]
Text

Debian 10 和 .NET 5

# Use the base runtime image for Debian 10 with .NET runtime
FROM mcr.microsoft.com/dotnet/runtime:5.0 AS base
WORKDIR /app

# Install necessary packages
RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev

# Use the base development image for Debian 10 with .NET SDK
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src

# Restore NuGet packages
COPY ["Example/Example.csproj", "Example/"]
RUN dotnet restore "Example/Example.csproj"

# Build the project
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build

# Publish the project
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish

# Run the application
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]
Text

Debian 10 及 .NET 3.1 LTS

# Use the base runtime image for Debian 10 with .NET runtime
FROM mcr.microsoft.com/dotnet/runtime:3.1 AS base
WORKDIR /app

# Install necessary packages
RUN apt-get update && apt-get install -y apt-utils libgdiplus libc6-dev

# Use the base development image for Debian 10 with .NET SDK
FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
WORKDIR /src

# Restore NuGet packages
COPY ["Example/Example.csproj", "Example/"]
RUN dotnet restore "Example/Example.csproj"

# Build the project
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build

# Publish the project
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish

# Run the application
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]
Text

常見問題

如何在 Docker 容器中部署 C# OCR 應用程式?

您可以使用 IronOCR(與 Docker 整合的 C# OCR 程式庫),將 C# OCR 應用程式部署在 Docker 容器中。您需要設置 Docker 容器,其中包括必要的套件如 apt-utilslibgdipluslibc6-dev,並使用微軟的官方 Docker 圖像以獲得最佳效能。

哪些操作系統最適合在 Docker 中運行 IronOCR?

要在 Docker 中運行 IronOCR,建議使用最新的 64 位 Linux 發行版,如 Ubuntu 20、Ubuntu 18、Debian 11 和 Debian 10,因為它們提供簡單的配置和支援。

如何在 Azure Docker 容器中配置 IronOCR?

要在 Azure Docker 容器中配置 IronOCR,您需要遵循與其他 Docker 環境相同的步驟。使用 IronOcr NuGet 套件,設置推薦的 Linux 發行版,並確保所有必要的依賴項都已包含在您的 Dockerfile 中。

在 Docker 中使用 .NET 5 設置 IronOCR 的步驟是什麼?

要在 Docker 中使用 .NET 5 設置 IronOCR,您需要建立一個 Dockerfile,該文件安裝 IronOcr NuGet 套件,新增所需的套件如 apt-utilslibgdiplus,並使用微軟官方的 .NET 5 Docker 圖像作為基礎圖像。

IronOCR 可以在 Windows 的 Docker 環境中使用嗎?

是的,IronOCR 可以在 Windows 的 Docker 環境中使用。這個過程涉及使用 IronOcr NuGet 套件並配置 Dockerfile 以包含 Windows 操作系統特定的必要依賴項和配置。

using Docker 託管 .NET OCR 應用程式有什麼好處?

using Docker 託管 .NET OCR 應用程式允許易於部署、更好的資源管理以及在不同環境間更大的可攜性。Docker 容器自給自足,確保應用程式無論在哪裡部署都能一致運行。

非推薦 Linux 發行版在 Docker 中需要手動配置嗎?

是的,如果您使用推薦以外的 Linux 發行版(Ubuntu 20、Ubuntu 18、Debian 11、Debian 10),則可能需要使用 apt-get 進行手動配置。有關手動設置的指導可在 IronOCR 提供的「Linux 手動設置」指南中找到。

Can I use IronOCR with Azure Docker Containers?

Yes, IronOCR is fully compatible with Azure Docker Containers, allowing you to deploy and run .NET OCR applications on both Linux and Windows platforms within the Azure ecosystem.

What is the best way to develop and debug Docker applications using IronOCR?

For those new to Docker with .NET, the documentation recommends resources from Microsoft on setting up Docker debugging and integration with Visual Studio projects. This approach facilitates a smoother development experience.

Are there any official Docker images recommended for IronOCR?

IronOCR recommends using Microsoft's Official Docker Images for running .NET applications. These images are designed to provide a high level of compatibility and performance for .NET-based applications.

Curtis Chau
技術作家

Curtis Chau擁有Carleton大學的電腦科學學士學位,專精於前端開發,擁有Node.js、TypeScript、JavaScript和React的專業知識。Curtis熱衷於建立直觀且美觀的使用者介面,喜愛使用現代框架並建立結構良好、視覺吸引力的手冊。

...
閱讀更多

準備開始了嗎?

Nuget Downloads 6,236,385版本:2026.9剛剛發布

立即獲取您的30天試用金鑰
無需信用卡或帳戶建立
C# PDF的NuGet程式庫
使用NuGet安裝

版本: 2026.9

PM > Install-Package IronOcr
nuget.org/packages/IronOcr/
  1. 在解決方案資源管理器中,右鍵點擊參考,管理NuGet包
  2. 選擇瀏覽並搜尋"IronOCR"
  3. 選擇包並安裝
C# PDF DLL
下載 DLL

版本: 2026.9

這裡下載Windows安裝程式。

  1. 下載並解壓IronOCR至您的方案目錄下的~/Libs等位置
  2. 在Visual Studio解決方案資源管理器中,右鍵點擊參考。選擇瀏覽,"IronOCR.dll"

授權從$999

有問題嗎?聯絡我們的開發團隊。

Key in blue circle

立即免費取得 30 天試用金鑰

Your trial license will be sent to your email address

無任何限制。100% 解鎖。無需信用卡。

bullet_checked無需信用卡或建立帳號無任何限制。100% 解鎖。無需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
獲取您的無義務諮詢
填寫以下表格或發送電子郵件至sales@ironsoftware.com
您的詳細資訊將始終保密。
被全球數百萬工程師信任
Iron Software的客戶標誌
立即獲取您的30天試用金鑰
無需信用卡或帳戶建立