Setting up IronBarcode in Docker Containers
IronBarcode fully supports Docker, including containers in Azure and AWS for Linux and Windows.





Why use Docker?
Docker enables developers to easily pack, ship, and run any application as a lightweight, portable, self-sufficient container, which can run virtually anywhere.
IronBarcode and Linux Primer
If Docker with .NET is new to you, we recommend this excellent article on setting up Docker debugging and integration with Visual Studio projects.
For working with IronBarcode in Linux, we also highly recommend you read our IronBarcode Linux setup and compatibility guide.
Recommended Linux Docker Distributions
We recommend using the following 64-bit Linux distributions for the least hassle in configuring IronBarcode:
- Ubuntu ≥18
- Debian ≥10
- CentOS ≥7
We recommend using Microsoft's official Docker images. Other Linux distros are supported in part, but may require manual configuration and dependency installations. See our Linux manual setup guide for more information on how to set up with Linux.
IronBarcode Linux Docker Installation Essentials
Use Our NuGet Package
We recommend using the IronBarCode NuGet Package—it works seamlessly when developing on Windows, macOS, and Linux.
Install-Package BarCode
Ubuntu Linux Dockerfiles


Ubuntu 22 with .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 with .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 with .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 with .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 with .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 with .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 with .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 with .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 with .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 with .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 with .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 with .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 with .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 with .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 with .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"]
Frequently Asked Questions
What is IronBarcode?
IronBarcode is a .NET library designed to read and write barcodes in a variety of formats. It supports integration with Docker on Linux.
Why use Docker for IronBarcode applications?
Docker allows developers to package applications into containers, making them lightweight, portable, and able to run consistently across different environments, including Linux and Windows.
Which Linux distributions are recommended for IronBarcode?
The recommended Linux distributions for IronBarcode are Ubuntu ≥18, Debian ≥10, and CentOS ≥7, as they provide the least hassle in configuration.
How can I install IronBarcode in a Docker container?
You can install IronBarcode in a Docker container by using the IronBarCode NuGet Package via the command: dotnet add package IronBarCode.
Where can I find more information on setting up Docker with .NET?
For more information on setting up Docker with .NET, you can refer to the Microsoft documentation on Docker debugging and integration with Visual Studio projects.
What are the steps to build a Docker image for IronBarcode on Ubuntu 22 with .NET 7?
The steps include setting up a base runtime image, installing necessary packages, restoring NuGet packages, building the project, publishing the project, and creating the final image to run the app.
Can I use IronBarcode with other Linux distributions?
Yes, IronBarcode can be used with other Linux distributions, but they may require manual configuration and dependency installations. Consult the Linux manual setup guide for more details.
What is the recommended way to manage dependencies for IronBarcode in Docker?
Managing dependencies through the IronBarCode NuGet Package is recommended, as it ensures seamless development across Windows, macOS, and Linux.
How do I choose between different .NET versions for my Docker setup?
Choosing a .NET version depends on your project requirements. LTS versions like .NET 6 or 3.1 are recommended for stability, whereas newer versions like .NET 7 offer the latest features.
Is IronBarcode compatible with cloud services like Azure or AWS?
Yes, IronBarcode is fully compatible with Docker containers running on cloud services such as Azure and AWS, supporting both Linux and Windows environments.