Configuración de IronOCR en contenedores Docker

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

¿Quieres realizar OCR en imágenes o archivos Pdf en C#?

IronOCR ahora es totalmente compatible con Docker, incluidos los contenedores de Docker de Azure para Linux y Windows.

Docker Linux AWS Windows

¿Por qué utilizar Docker?

Docker permite a los desarrolladores empaquetar, enviar y ejecutar fácilmente cualquier aplicación como un contenedor independiente, portátil y liviano, que puede ejecutarse en casi cualquier lugar.

Introducción a IronOCR y Linux

Si Docker con .NET es nuevo para ti, te recomendamos este excelente artículo sobre la configuración de depuración de Docker e integración con proyectos de Visual Studio. https://docs.microsoft.com/en-us/visualstudio/containers/edit-and-refresh?view=vs-2019

También le recomendamos encarecidamente que lea nuestra Guía de configuración y compatibilidad de IronOCR para Linux.

Distribuciones recomendadas de Docker para Linux

Recomendamos las últimas OS de Linux de 64 bits a continuación para una "configuración fácil" de IronPDF.

  • Ubuntu 20
  • Ubuntu 18
  • Debian 11
  • Debian 10 [Actualmente la distribución Linux predeterminada de Microsoft Azure]

Recomendamos usar las imágenes oficiales de Docker de Microsoft. Otras distribuciones de Linux son soportadas en parte, pero pueden requerir configuración manual usando apt-get. Vea nuestra guía de "Configuración manual de Linux".

Archivos Docker funcionales para Ubuntu y Debian están incluidos en este documento:

Fundamentos de la instalación de IronOCR en Docker para Linux

Utilice nuestro paquete NuGet

Recomendamos utilizar el paquete NuGet IronOCR. Funciona cuando se desarrolla en Windows, macOS y Linux.

Install-Package IronOcr

Archivos Docker de Ubuntu Linux

Docker Linux Ubuntu

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

Archivos Docker de Debian Linux

Docker Linux Debian

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

Preguntas Frecuentes

¿Cómo puedo desplegar aplicaciones OCR de C# en contenedores Docker?

Puedes implementar aplicaciones de OCR en C# en contenedores Docker utilizando IronOCR, una biblioteca de OCR en C# que se integra con Docker. Deberás configurar los contenedores Docker con los paquetes necesarios como apt-utils, libgdiplus y libc6-dev, y usar las imágenes oficiales de Docker de Microsoft para un rendimiento óptimo.

¿Qué sistemas operativos son mejores para ejecutar IronOCR en Docker?

Para ejecutar IronOCR en Docker, se recomienda utilizar las últimas distribuciones de Linux de 64 bits como Ubuntu 20, Ubuntu 18, Debian 11 y Debian 10, ya que ofrecen fácil configuración y soporte.

¿Cómo configuro IronOCR en contenedores Docker de Azure?

Para configurar IronOCR en contenedores Docker de Azure, seguirías los mismos pasos que para otros entornos Docker. Usa el paquete NuGet de IronOcr, configura las distribuciones de Linux recomendadas, y asegúrate de que todas las dependencias necesarias estén incluidas en tu Dockerfile.

¿Cuáles son los pasos para configurar IronOCR usando .NET 5 en Docker?

Para configurar IronOCR utilizando .NET 5 en Docker, necesitas crear un Dockerfile que instale el paquete NuGet IronOcr, añada paquetes requeridos como apt-utils y libgdiplus, y utilice las imágenes oficiales de Docker de .NET 5 de Microsoft como imagen base.

¿Puede IronOCR usarse en entornos Docker en Windows?

Sí, IronOCR puede usarse en entornos Docker en Windows. El proceso implica usar el paquete NuGet de IronOcr y configurar el Dockerfile para incluir las dependencias necesarias y configuraciones específicas para sistemas operativos Windows.

¿Cuáles son los beneficios de usar Docker para alojar aplicaciones OCR de .NET?

Usar Docker para alojar aplicaciones OCR de .NET permite una fácil implementación, mejor gestión de recursos y mayor portabilidad entre diferentes entornos. Los contenedores Docker son autosuficientes, asegurando que las aplicaciones se ejecuten de manera consistente sin importar dónde se desplieguen.

¿Se requiere configuración manual para distribuciones de Linux no recomendadas en Docker?

Sí, si estás utilizando distribuciones de Linux diferentes a las recomendadas (Ubuntu 20, Ubuntu 18, Debian 11, Debian 10), es posible que debas realizar configuraciones manuales utilizando apt-get. La guía sobre la configuración manual está disponible en la guía 'Configuración Manual de Linux' proporcionada por IronOCR.

Curtis Chau
Escritor Técnico

Curtis Chau tiene una licenciatura en Ciencias de la Computación (Carleton University) y se especializa en el desarrollo front-end con experiencia en Node.js, TypeScript, JavaScript y React. Apasionado por crear interfaces de usuario intuitivas y estéticamente agradables, disfruta trabajando con frameworks modernos y creando manuales bien ...

Leer más
¿Listo para empezar?
Nuget Descargas 5,167,857 | Version: 2025.11 recién lanzado