Konfiguracja IronOCR w kontenerach Docker

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

Chcesz przetwarzać obrazy lub pliki Pdf w C# za pomocą OCR?

IronOCR teraz w pełni obsługuje Docker, w tym kontenery Docker na platformie Azure dla systemów Linux i Windows.

Docker Linux AWS Windows

Dlaczego warto korzystać z Docker?

Docker umożliwia programistom łatwe pakowanie, dostarczanie i uruchamianie dowolnej aplikacji jako lekkiego, przenośnego i samowystarczalnego kontenera, który może działać praktycznie wszędzie.

IronOCR i wprowadzenie do Linuxa

Jeśli Docker z .NET jest dla Ciebie nowością, polecamy doskonały artykuł o konfigurowaniu debugowania Docker i integracji z projektami Visual Studio. https://docs.microsoft.com/en-us/visualstudio/containers/edit-and-refresh?view=vs-2019

Zalecamy również przeczytanie naszego Przewodnika po konfiguracji i zgodności IronOCR z Linuxem.

Zalecane dystrybucje Linux Docker

Zalecamy najnowsze 64-bitowe systemy Linux, wymienione poniżej, dla 'łatwej konfiguracji' IronOCR.

  • Ubuntu 20
  • Ubuntu 18
  • Debian 11
  • Debian 10 [Obecnie domyślna dystrybucja Linux Microsoft Azure]

Polecamy użycie Oficjalnych Obrazów Docker Microsoft. Inne dystrybucje Linux są częściowo obsługiwane, ale mogą wymagać ręcznej konfiguracji przy użyciu apt-get. Zobacz nasz przewodnik "Ręczna konfiguracja Linuxa".

Działające pliki Docker dla Ubuntu i Debian są zawarte w tym dokumencie:

Podstawy instalacji IronOCR na Dockerze w Linuxie

Skorzystaj z naszego pakietu NuGet

Zalecamy użycie pakietu NuGet IronOcr. Działa podczas tworzenia aplikacji na Windows, macOS i Linux.

Install-Package IronOcr

Pliki Docker dla Linux Ubuntu

Docker Linux Ubuntu

Ubuntu 20 z .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"]

Ubuntu 20 z .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"]

Ubuntu 18 z .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"]

Pliki Docker dla Debian Linux

Docker Linux Debian

Debian 11 z .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"]

Debian 11 z .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"]

Debian 10 z .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"]

Debian 10 z .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"]

Często Zadawane Pytania

How can I deploy C# OCR applications in Docker containers?

You can deploy C# OCR applications in Docker containers by using IronOCR, a C# OCR library that integrates with Docker. You'll need to set up the Docker containers with the necessary packages like apt-utils, libgdiplus, and libc6-dev, and use Microsoft's official Docker images for optimal performance.

Which operating systems are best for running IronOCR in Docker?

For running IronOCR in Docker, it is recommended to use the latest 64-bit Linux distributions such as Ubuntu 20, Ubuntu 18, Debian 11, and Debian 10, as they offer easy configuration and support.

How do I configure IronOCR on Azure Docker Containers?

To configure IronOCR on Azure Docker Containers, you would follow the same steps as for other Docker environments. Use the IronOcr NuGet package, set up the recommended Linux distributions, and ensure all necessary dependencies are included in your Dockerfile.

What are the steps to set up IronOCR using .NET 5 in Docker?

To set up IronOCR using .NET 5 in Docker, you need to create a Dockerfile that installs the IronOcr NuGet package, adds required packages like apt-utils and libgdiplus, and uses Microsoft's official .NET 5 Docker images for the base image.

Can IronOCR be used in Docker environments on Windows?

Yes, IronOCR can be used in Docker environments on Windows. The process involves using the IronOcr NuGet package and configuring the Dockerfile to include necessary dependencies and configurations specific to Windows operating systems.

What are the benefits of using Docker for hosting .NET OCR applications?

Using Docker for hosting .NET OCR applications allows for easy deployment, better resource management, and greater portability across different environments. Docker containers are self-sufficient, ensuring that the applications run consistently regardless of where they are deployed.

Is manual configuration required for non-recommended Linux distributions in Docker?

Yes, if you are using Linux distributions other than the recommended ones (Ubuntu 20, Ubuntu 18, Debian 11, Debian 10), you might need to perform manual configurations using apt-get. Guidance on manual setup is available in the 'Linux Manual Setup' guide provided by IronOCR.

Curtis Chau
Autor tekstów technicznych

Curtis Chau posiada tytuł licencjata z informatyki (Uniwersytet Carleton) i specjalizuje się w front-endowym rozwoju, z ekspertką w Node.js, TypeScript, JavaScript i React. Pasjonuje się tworzeniem intuicyjnych i estetycznie przyjemnych interfejsów użytkownika, Curtis cieszy się pracą z nowoczesnymi frameworkami i tworzeniem dobrze zorganizowanych, atrakcyjnych wizualnie podrę...

Czytaj więcej
Gotowy, aby rozpocząć?
Nuget Pliki do pobrania 5,571,678 | Wersja: 2026.4 just released
Still Scrolling Icon

Wciąż przewijasz?

Czy chcesz szybko dowodu? PM > Install-Package IronOcr
uruchom próbkę obserwuj, jak twój obraz staje się tekstem z możliwością wyszukiwania.