Setting up IronBarcode in Docker Containers

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

IronBarcode prend entièrement en charge Docker, y compris les conteneurs dans Azure et AWS pour Linux et Windows.

class="main-content__small-images-inline"> Docker Azure Linux Amazon Windows

Pourquoi utiliser Docker ?

Docker permet aux développeurs de facilement empaqueter, déployer et exécuter toute application en tant que conteneur léger, portable et autonome, qui peut fonctionner pratiquement n'importe où.

IronBarcode et Présentation de Linux

Si Docker avec .NET est nouveau pour vous, nous vous recommandons cet excellent article sur la configuration du débogage Docker et l'intégration avec des projets Visual Studio.

Pour travailler avec IronBarcode sous Linux, nous vous recommandons également vivement de lire notre guide de configuration et de compatibilité IronBarcode Linux.

Distributions Linux Docker Recommandées

Nous recommandons d'utiliser les distributions Linux 64 bits suivantes pour la moindre difficulté lors de la configuration d'IronBarcode :

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

Nous recommandons d'utiliser les images Docker officielles de Microsoft. D'autres distributions Linux sont partiellement prises en charge, mais peuvent nécessiter une configuration manuelle et des installations de dépendances. Consultez notre guide de configuration manuelle sous Linux pour plus d'informations sur la configuration avec Linux.

Essentiels de l'installation d'IronBarcode Linux Docker

Utilisez Notre Package NuGet

Nous vous recommandons d'utiliser le Package NuGet IronBarCode—il fonctionne parfaitement lors du développement sur Windows, macOS et Linux.

Install-Package BarCode

Dockerfiles Ubuntu Linux

class="main-content__small-images-inline"> Docker Ubuntu

Ubuntu 22 avec .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 avec .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 avec .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 avec .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 avec .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 avec .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"]

DockerFiles Debian Linux

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

Questions Fréquemment Posées

Comment puis-je configurer une application de code-barres dans Docker sur Linux?

Pour configurer une application de code-barres dans Docker sur Linux, vous pouvez utiliser IronBarcode. Commencez par extraire l'image Docker .NET appropriée, installez le paquet NuGet IronBarcode en utilisant dotnet add package IronBarCode, et configurez votre Dockerfile pour construire et exécuter votre application dans un conteneur.

Quelles distributions Linux sont les meilleures pour exécuter Docker avec des applications de code-barres?

Les distributions Linux recommandées pour exécuter Docker avec des applications de code-barres en utilisant IronBarcode sont Ubuntu ≥18, Debian ≥10 et CentOS ≥7 en raison de leur facilité de configuration et de leur stabilité.

Quels sont les avantages d'utiliser Docker pour les applications de code-barres?

Utiliser Docker pour les applications de code-barres permet de les conteneuriser, ce qui rend les applications légères, portables et cohérentes dans différents environnements. Cela est particulièrement bénéfique pour le déploiement sur des services cloud comme Azure et AWS.

Comment résoudre les problèmes de configuration Docker avec les bibliothèques de code-barres?

Les problèmes courants dans les configurations Docker avec les bibliothèques de code-barres peuvent souvent être résolus en veillant à ce que toutes les dépendances soient correctement installées et que le Dockerfile soit correctement configuré. Utiliser les images officielles Microsoft .NET peut faciliter le processus.

Puis-je exécuter des applications de code-barres dans Docker sur les plateformes cloud?

Oui, vous pouvez exécuter des applications de code-barres dans des conteneurs Docker sur des plateformes cloud telles qu'Azure et AWS. IronBarcode supporte ces environnements, que ce soit sur Linux ou Windows.

Quel est le processus d'installation de la bibliothèque de code-barres dans un conteneur Docker?

Installez la bibliothèque IronBarcode dans un conteneur Docker en ajoutant le paquet NuGet IronBarCode à votre projet .NET en utilisant dotnet add package IronBarCode dans votre processus de configuration Docker.

Comment assurer la compatibilité des applications de code-barres entre différents environnements?

Pour assurer la compatibilité entre différents environnements, utilisez Docker pour conteneuriser votre application de code-barres et gérer les dépendances via le paquet NuGet IronBarCode. Cette approche fournit un environnement cohérent pour votre application.

Quelles versions de .NET sont recommandées pour construire des images Docker pour les applications de code-barres?

Il est recommandé d'utiliser les versions LTS de .NET, telles que .NET 6 ou 3.1, pour la stabilité lors de la construction d'images Docker pour les applications de code-barres. Cependant, utiliser la version la plus récente comme .NET 7 peut fournir accès aux fonctionnalités les plus récentes.

IronBarcode est-il compatible avec .NET 10 et puis-je l'utiliser dans Docker sous Linux avec .NET 10 ?

Oui. IronBarcode est compatible avec .NET 10, ainsi qu'avec .NET 9, 8, 7, 6, 5, .NET Core, .NET Standard et .NET Framework 4.6.2 et versions ultérieures. Il fonctionne également dans les conteneurs Docker sous Linux. ([ironsoftware.com](https://ironsoftware.com/csharp/barcode/features/compatibility/?utm_source=openai))

Curtis Chau
Rédacteur technique

Curtis Chau détient un baccalauréat en informatique (Université de Carleton) et se spécialise dans le développement front-end avec expertise en Node.js, TypeScript, JavaScript et React. Passionné par la création d'interfaces utilisateur intuitives et esthétiquement plaisantes, Curtis aime travailler avec des frameworks modernes ...

Lire la suite
Prêt à commencer?
Nuget Téléchargements 1,935,276 | Version : 2025.11 vient de sortir