Setting up IronBarCode in Docker Containers

Want to Read/Generate BarCode Using C#?

IronBarCode now fully supports Docker, including Azure Docker Containers for Linux and Windows.

Docker Azure Linux Amazon 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. https://docs.microsoft.com/en-us/visualstudio/containers/edit-and-refresh?view=vs-2019

We also highly recommend you read our IronBarCode Linux Setup and Compatibility Guide

We recommend the latest 64 bit Linux OS's below for "easy configuration" of IronBarCode.

  • Ubuntu 22
  • Ubuntu 20
  • Ubuntu 18
  • Debian 11
  • Debian 10 [Currently the Microsoft Azure Default Linux Distro]
  • CentOS 7

We recommend using Microsoft's Official Docker Images . Other Linux distros are supported in part, but may require manual configuration using apt-get. See our "Linux Manual Setup" guide

Working Docker files for Ubuntu and Debian are included In this document:

IronBarCode Linux Docker Installation Essentials

Use Our NuGet Package

We recommend using the IronBarCode NuGet Package it works when developing on Windows , macOS and Linux.

Install-Package BarCode

Ubuntu Linux DockerFiles

Docker Ubuntu

Ubuntu 22 with .NET 7

# base runtime image (Ubuntu 22 w/ .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 w/ .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
# run 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 w/ .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 w/ .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
# run 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 w/ .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 w/ .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
# run 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 w/ .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 w/ .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
# run 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 w/ .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 w/ .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
# run 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 w/ .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 w/ .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
# run 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 w/ 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 w/ .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
# run 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 w/ 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 w/ .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
# run 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 w/ 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 w/ .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
# run 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 w/ 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 w/ .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
# run 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 w/ .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 w/ .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
# run 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 w/ .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 w/ .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
# run 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
# run 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
# run 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
# run app
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]