Setting up IronBarcode in Docker Containers

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

IronBarcode unterstützt vollständig Docker, einschließlich Containern in Azure und AWS für Linux und Windows.

class="main-content__small-images-inline">DockerAzureLinuxAmazonWindows

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.

IronBarcode und Linux-Leitfaden

Falls Docker mit .NET neu für Sie ist, empfehlen wir diesen hervorragenden Artikel über das Einrichten von Docker-Debugging und die Integration mit Visual Studio-Projekten.

Zum Arbeiten mit IronBarcode in Linux empfehlen wir dringend, unseren IronBarcode Linux Einrichtungs- und Kompatibilitätsleitfaden zu lesen.

Empfohlene Linux-Docker-Distributionen

Wir empfehlen, die folgenden 64-Bit-Linux-Distributionen zu verwenden, um den geringsten Aufwand bei der Konfiguration von IronBarcode zu haben:

  • Ubuntu ≥18
  • Debian ≥10
  • CentOS ≥7

Wir empfehlen die offiziellen Docker-Images von Microsoft. Andere Linux-Distros werden teilweise unterstützt, erfordern jedoch möglicherweise manuelle Konfiguration und Abhängigkeitsinstallationen. Siehe unseren Linux-Handbuch Einrichtungsleitfaden für weitere Informationen zum Einrichten mit Linux.

Wesentliche Installationselemente von IronBarcode Linux Docker

Nutzen Sie unser NuGet-Paket

Wir empfehlen die Verwendung des IronBarCode NuGet-Pakets—es funktioniert nahtlos bei der Entwicklung unter Windows, macOS und Linux.

Install-Package BarCode

Ubuntu Linux Dockerfiles

class="main-content__small-images-inline">DockerUbuntu

Ubuntu 22 mit .NET 7

# Base runtime image (Ubuntu 22 with .NET runtime)
FROM mcr.microsoft.com/dotnet/runtime:7.0-jammy AS base
WORKDIR /app

# Install necessary packages
RUN apt update

# Base development image (Ubuntu 22 with .NET SDK)
FROM mcr.microsoft.com/dotnet/sdk:7.0-jammy AS build
WORKDIR /src

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

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

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

# Final image to run the app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]

Ubuntu 22 mit .NET 6 (LTS)

# Base runtime image (Ubuntu 22 with .NET runtime)
FROM mcr.microsoft.com/dotnet/runtime:6.0-jammy AS base
WORKDIR /app

# Install necessary packages
RUN apt update

# Base development image (Ubuntu 22 with .NET SDK)
FROM mcr.microsoft.com/dotnet/sdk:6.0-jammy AS build
WORKDIR /src

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

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

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

# Final image to run the app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]

Ubuntu 20 mit .NET 6 (LTS)

# Base runtime image (Ubuntu 20 with .NET runtime)
FROM mcr.microsoft.com/dotnet/runtime:6.0-focal AS base
WORKDIR /app

# Install necessary packages
RUN apt update

# Base development image (Ubuntu 20 with .NET SDK)
FROM mcr.microsoft.com/dotnet/sdk:6.0-focal AS build
WORKDIR /src

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

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

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

# Final image to run the app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]

Ubuntu 20 mit .NET 5

# Base runtime image (Ubuntu 20 with .NET runtime)
FROM mcr.microsoft.com/dotnet/runtime:5.0-focal AS base
WORKDIR /app

# Install necessary packages
RUN apt update

# Base development image (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 project
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build

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

# Final image to run the app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]

Ubuntu 20 mit .NET 3.1 LTS

# Base runtime image (Ubuntu 20 with .NET runtime)
FROM mcr.microsoft.com/dotnet/runtime:3.1-focal AS base
WORKDIR /app

# Install necessary packages
RUN apt update

# Base development image (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 project
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build

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

# Final image to run the app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]

Ubuntu 18 mit .NET 3.1 LTS

# Base runtime image (Ubuntu 18 with .NET runtime)
FROM mcr.microsoft.com/dotnet/runtime:3.1-bionic AS base
WORKDIR /app

# Install necessary packages
RUN apt update

# Base development image (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 project
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build

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

# Final image to run the app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]

Debian Linux DockerFiles

Debian 11 mit .NET 7

# Base runtime image (Debian 11 with ASP.NET Core Runtime)
FROM mcr.microsoft.com/dotnet/aspnet:7.0-bullseye-slim AS base
WORKDIR /app

# Install necessary packages
RUN apt update

# Base development image (Debian 11 with .NET SDK)
FROM mcr.microsoft.com/dotnet/sdk:7.0-bullseye-slim AS build
WORKDIR /src

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

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

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

# Final image to run the app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]

Debian 11 mit .NET 6 (LTS)

# Base runtime image (Debian 11 with ASP.NET Core Runtime)
FROM mcr.microsoft.com/dotnet/aspnet:6.0-bullseye-slim AS base
WORKDIR /app

# Install necessary packages
RUN apt update

# Base development image (Debian 11 with .NET SDK)
FROM mcr.microsoft.com/dotnet/sdk:6.0-bullseye-slim AS build
WORKDIR /src

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

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

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

# Final image to run the app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]

Debian 11 mit .NET 5

# Base runtime image (Debian 11 with ASP.NET Core Runtime)
FROM mcr.microsoft.com/dotnet/aspnet:5.0-bullseye-slim AS base
WORKDIR /app

# Install necessary packages
RUN apt update

# Base development image (Debian 11 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 project
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build

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

# Final image to run the app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]

Debian 11 mit .NET 3.1 LTS

# Base runtime image (Debian 11 with ASP.NET Core Runtime)
FROM mcr.microsoft.com/dotnet/aspnet:3.1-bullseye-slim AS base
WORKDIR /app

# Install necessary packages
RUN apt update

# Base development image (Debian 11 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 project
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build

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

# Final image to run the app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]

Debian 10 mit .NET 5

# Base runtime image (Debian 10 with .NET runtime)
FROM mcr.microsoft.com/dotnet/runtime:5.0 AS base
WORKDIR /app

# Install necessary packages
RUN apt update

# Base development image (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 project
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build

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

# Final image to run the app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]

Debian 10 mit .NET 3.1 LTS

# Base runtime image (Debian 10 with .NET runtime)
FROM mcr.microsoft.com/dotnet/runtime:3.1 AS base
WORKDIR /app

# Install necessary packages
RUN apt update

# Base development image (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 project
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build

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

# Final image to run the app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]

CentOS 7 mit .NET 7

# Base runtime image (CentOS 7)
FROM centos:7 as base

# Install necessary packages
RUN rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
RUN yum install -y dotnet-runtime-7.0
WORKDIR /app

# Build SDK image (CentOS 7)
FROM centos:7 as build

# Install necessary packages
RUN rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
RUN yum install -y dotnet-sdk-7.0

WORKDIR /src

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

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

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

# Final image to run the app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]

CentOS 7 mit .NET 6 (LTS)

# Base runtime image (CentOS 7)
FROM centos:7 as base

# Install necessary packages
RUN rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
RUN yum install -y dotnet-runtime-6.0
WORKDIR /app

# Build SDK image (CentOS 7)
FROM centos:7 as build

# Install necessary packages
RUN rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
RUN yum install -y dotnet-sdk-6.0

WORKDIR /src

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

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

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

# Final image to run the app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]

CentOS 7 mit .NET 3.1 LTS

# Base runtime image (CentOS 7)
FROM centos:7 AS base

# Install necessary packages
RUN yum install sudo -y
RUN sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
RUN sudo yum install aspnetcore-runtime-3.1 -y

WORKDIR /app
EXPOSE 80
EXPOSE 443

# Build SDK image (CentOS 7)
FROM centos:7 AS build

# Install necessary packages
RUN yum install sudo -y
RUN sudo rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
RUN sudo yum install dotnet-sdk-3.1 -y

WORKDIR /src

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

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

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

# Final image to run the app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]

Häufig gestellte Fragen

Wie kann ich eine Barcode-Anwendung in Docker auf Linux einrichten?

Um eine Barcode-Anwendung in Docker auf Linux einzurichten, können Sie IronBarcode verwenden. Beginnen Sie mit dem Herunterladen des entsprechenden .NET Docker-Images, installieren Sie das IronBarcode NuGet-Paket mit dotnet add package IronBarCode und konfigurieren Sie Ihre Dockerfile, um Ihre Anwendung in einem Container zu erstellen und auszuführen.

Welche Linux-Distributionen sind am besten für das Ausführen von Docker mit Barcode-Anwendungen geeignet?

Die empfohlenen Linux-Distributionen für das Ausführen von Docker mit Barcode-Anwendungen unter Verwendung von IronBarcode sind Ubuntu ≥18, Debian ≥10 und CentOS ≥7, da sie eine einfache Konfiguration und Stabilität bieten.

Was sind die Vorteile der Verwendung von Docker für Barcode-Anwendungen?

Die Verwendung von Docker für Barcode-Anwendungen ermöglicht die Containerisierung, was Anwendungen leicht, portabel und konsistent über verschiedene Umgebungen hinweg macht. Dies ist besonders vorteilhaft für die Bereitstellung von Anwendungen auf Cloud-Diensten wie Azure und AWS.

Wie behebe ich Einrichtungsprobleme mit Docker für Barcode-Bibliotheken?

Häufige Probleme bei Docker-Setups mit Barcode-Bibliotheken können oft gelöst werden, indem alle Abhängigkeiten korrekt installiert und die Dockerfile ordnungsgemäß konfiguriert werden. Die Verwendung der offiziellen Microsoft .NET-Images kann den Prozess vereinfachen.

Kann ich Barcode-Anwendungen in Docker auf Cloud-Plattformen ausführen?

Ja, Sie können Barcode-Anwendungen in Docker-Containern auf Cloud-Plattformen wie Azure und AWS ausführen. IronBarcode unterstützt diese Umgebungen, unabhängig davon, ob es sich um Linux- oder Windows-Plattformen handelt.

Wie ist der Prozess zur Installation der Barcode-Bibliothek in einem Docker-Container?

Installieren Sie die IronBarcode-Bibliothek in einem Docker-Container, indem Sie das IronBarCode NuGet-Paket zu Ihrem .NET-Projekt hinzufügen, indem Sie in Ihrem Docker-Setup-Prozess dotnet add package IronBarCode verwenden.

Wie stelle ich die Kompatibilität von Barcode-Anwendungen über verschiedene Umgebungen sicher?

Um die Kompatibilität über verschiedene Umgebungen hinweg sicherzustellen, verwenden Sie Docker zur Containerisierung Ihrer Barcode-Anwendung und verwalten Sie Abhängigkeiten über das IronBarcode NuGet Package. Dieser Ansatz bietet eine konsistente Umgebung für Ihre Anwendung.

Was sind die empfohlenen .NET-Versionen zum Erstellen von Docker-Images für Barcode-Anwendungen?

Es wird empfohlen, LTS-Versionen von .NET wie .NET 6 oder 3.1 für Stabilität bei der Erstellung von Docker-Images für Barcode-Anwendungen zu verwenden. Allerdings kann die Verwendung der neuesten Version wie .NET 7 Zugriff auf die neuesten Funktionen bieten.

Ist IronBarcode mit .NET 10 kompatibel und kann ich es in Docker unter Linux mit .NET 10 verwenden?

Ja. IronBarcode unterstützt .NET 10 – sowie .NET 9, 8, 7, 6, 5, .NET Core, .NET Standard und .NET Framework 4.6.2+ – und läuft in Docker-Containern unter Linux. ([ironsoftware.com](https://ironsoftware.com/csharp/barcode/features/compatibility/?utm_source=openai))

Curtis Chau
Technischer Autor

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 ...

Weiterlesen
Bereit anzufangen?
Nuget Downloads 1,935,276 | Version: 2025.11 gerade veröffentlicht