Einrichten von IronOCR in Docker-Containern
Wollen Sie Bilder oder PDF-Dateien in C# OCRen?
IronOCR unterstützt jetzt vollständig Docker, einschließlich Azure Docker-Containern für Linux und Windows.
Warum Docker verwenden?
Docker ermöglicht es Entwicklern, jede Anwendung als leichtgewichtigen, portablen, eigenständigen Container einfach zu verpacken, zu versenden und auszuführen, der praktisch überall laufen kann.
IronOCR und Linux-Grundlagen
Wenn Docker mit .NET neu für Sie ist, empfehlen wir diesen ausgezeichneten Artikel über das Einrichten von Docker-Debugging und die Integration in Visual Studio-Projekte. https://docs.microsoft.com/en-us/visualstudio/containers/edit-and-refresh?view=vs-2019
Wir empfehlen Ihnen auch dringend, unseren IronOCR Linux Einrichtungs- und Kompatibilitätsleitfaden zu lesen.
Empfohlene Linux-Docker-Distributionen
Wir empfehlen die neuesten 64-Bit-Linux-Betriebssysteme unten für eine "einfache Konfiguration" von IronPDF.
- Ubuntu 20
- Ubuntu 18
- Debian 11
- Debian 10 [Derzeit der Microsoft Azure Standard-Linux-Distro]
Wir empfehlen die Verwendung von Microsofts Offiziellen Docker Images. Andere Linux-Distributionen werden teilweise unterstützt, erfordern jedoch möglicherweise eine manuelle Konfiguration mit apt-get. Siehe unseren "Linux-Manuellen Einrichtungsleitfaden".
Funktionsfähige Docker-Dateien für Ubuntu und Debian sind in diesem Dokument enthalten:
IronOCR-Linux-Docker-Installationsanforderungen
Nutzen Sie unser NuGet-Paket
Wir empfehlen das IronOCR NuGet-Paket zu verwenden. Es funktioniert beim Entwickeln unter Windows, macOS und Linux.
Ubuntu Linux DockerFiles
Ubuntu 20 mit .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 mit .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 mit .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"]
Debian Linux DockerFiles
Debian 11 mit .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 mit .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 mit .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 mit .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"]
Häufig gestellte Fragen
Wie kann ich C# OCR-Anwendungen in Docker-Containern bereitstellen?
Sie können C# OCR-Anwendungen in Docker-Containern bereitstellen, indem Sie IronOCR verwenden, eine C#-OCR-Bibliothek, die mit Docker integriert ist. Sie müssen die Docker-Container mit den notwendigen Paketen wie apt-utils, libgdiplus und libc6-dev einrichten und Microsofts offizielle Docker-Images für optimale Leistung verwenden.
Welche Betriebssysteme eignen sich am besten für die Ausführung von IronOCR in Docker?
Für die Ausführung von IronOCR in Docker wird empfohlen, die neuesten 64-Bit-Linux-Distributionen wie Ubuntu 20, Ubuntu 18, Debian 11 und Debian 10 zu verwenden, da sie eine einfache Konfiguration und Unterstützung bieten.
Wie konfiguriere ich IronOCR auf Azure Docker-Containern?
Um IronOCR auf Azure Docker-Containern zu konfigurieren, befolgen Sie die gleichen Schritte wie für andere Docker-Umgebungen. Verwenden Sie das IronOcr NuGet-Paket, richten Sie die empfohlenen Linux-Distributionen ein und stellen Sie sicher, dass alle notwendigen Abhängigkeiten in Ihrem Dockerfile enthalten sind.
Welche Schritte gibt es, um IronOCR mit .NET 5 in Docker einzurichten?
Um IronOCR mit .NET 5 in Docker einzurichten, müssen Sie ein Dockerfile erstellen, das das IronOcr NuGet-Paket installiert, erforderliche Pakete wie apt-utils und libgdiplus hinzufügt und die offiziellen .NET 5 Docker-Bilder von Microsoft für das Basisimage verwendet.
Kann IronOCR in Docker-Umgebungen auf Windows verwendet werden?
Ja, IronOCR kann in Docker-Umgebungen auf Windows verwendet werden. Der Prozess beinhaltet die Verwendung des IronOcr NuGet-Pakets und die Konfiguration des Dockerfiles, um notwendige Abhängigkeiten und Konfigurationen spezifisch für Windows-Betriebssysteme einzuschließen.
Was sind die Vorteile der Verwendung von Docker zum Hosten von .NET OCR-Anwendungen?
Die Verwendung von Docker zum Hosten von .NET OCR-Anwendungen ermöglicht eine einfache Bereitstellung, eine bessere Ressourcenverwaltung und eine größere Portabilität zwischen verschiedenen Umgebungen. Docker-Container sind eigenständig und sorgen dafür, dass Anwendungen unabhängig davon, wo sie bereitgestellt werden, konsistent ausgeführt werden.
Ist eine manuelle Konfiguration für nicht empfohlene Linux-Distributionen in Docker erforderlich?
Ja, wenn Sie Linux-Distributionen verwenden, die von den empfohlenen (Ubuntu 20, Ubuntu 18, Debian 11, Debian 10) abweichen, müssen Sie möglicherweise manuelle Konfigurationen mit apt-get durchführen. Anleitungen zur manuellen Einrichtung finden Sie im Leitfaden 'Linux Manual Setup', der von IronOCR bereitgestellt wird.
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 hat einen Bachelor-Abschluss in Informatik von der Carleton University und ist spezialisiert auf Frontend-Entwicklung mit Expertise in Node.js, TypeScript, JavaScript und React. Leidenschaftlich widmet er sich der Erstellung intuitiver und ästhetisch ansprechender Benutzerschnittstellen und arbeitet gerne mit modernen Frameworks sowie der Erstellung gut strukturierter, optisch ansprechender Handbücher.