Setting up IronWord in Docker Containers
IronWord is fully supported in Docker containers for both Linux and Windows environments, making it ideal for deployment on Azure, AWS, or any . NET-ready host.
Why Use Docker?
Docker lets you package and run IronWord as a lightweight, self-contained container. This ensures consistent behavior across development, testing, and production—especially valuable when generating or manipulating Word documents programmatically.
IronWord supports .NET 5-9, .NET Standard (2.x, 3.x), and .NET Framework 4.6.2+, all of which work seamlessly in Docker on Linux and Windows.
Recommended Linux Docker Distributions
We recommend the following 64‑bit Linux distros for smooth IronWord operation:
- Ubuntu 22.04+ (Jammy)
- Ubuntu 20.04 (Focal)
- Debian 11+ (Bullseye)
- CentOS7+
Use Microsoft’s official Docker images with the .NET runtime and SDK to simplify setup and dependency management
IronWord NuGet Package
IronWord is easily added to any .NET project through its NuGet package. Simply run the following command in the NuGet Package Manager Console, and it will add the library automatically:
Install-Package IronWord
Ubuntu Dockerfile Examples
Ubuntu22 + .NET8
FROM mcr.microsoft.com/dotnet/runtime:8.0-jammy AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:8.0-jammy AS build
WORKDIR /src
COPY ["Example/Example.csproj", "Example/"]
RUN dotnet restore "Example/Example.csproj"
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]
Ubuntu20.04 + .NET6 (LTS)
FROM mcr.microsoft.com/dotnet/runtime:6.0-focal AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:6.0-focal AS build
WORKDIR /src
COPY ["Example/Example.csproj", "Example/"]
RUN dotnet restore "Example/Example.csproj"
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]
Debian Dockerfile Example
Debian11 + .NET7
FROM mcr.microsoft.com/dotnet/aspnet:7.0-bullseye-slim AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:7.0-bullseye-slim AS build
WORKDIR /src
COPY ["Example/Example.csproj", "Example/"]
RUN dotnet restore "Example/Example.csproj"
COPY . .
WORKDIR "/src/Example"
RUN dotnet build "Example.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Example.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Example.dll"]
CentOS 7
Use CentOS-based .NET runtimes like mcr.microsoft.com/dotnet/runtime:6.0-centos7 for IronWord compatibility.
# Build stage
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /app
COPY ./Example/Example.csproj ./Example/
RUN dotnet restore "./Example/Example.csproj"
COPY ./Example ./Example/
WORKDIR /app/Example
RUN dotnet publish -c Release -o /out
# Runtime stage - CentOS 7
FROM mcr.microsoft.com/dotnet/runtime:6.0-centos7 AS runtime
WORKDIR /app
RUN yum install -y liberation-fonts && yum clean all
COPY --from=build /out ./
ENTRYPOINT ["dotnet", "Example.dll"]
Notes & Troubleshooting
- IronWord fully supports .NET5–9, .NET Standard (2.x, 3.x), and .NET Framework 4.6.2+.
- Install fonts if needed (e.g., fonts-liberation, ttf-mscorefonts-installer) on Linux containers for proper rendering.
Frequently Asked Questions
What is IronWord and why use it in a Docker container?
IronWord is a library for working with Word documents in .NET applications. Using it in a Docker container allows for consistent behavior across development, testing, and production environments on both Linux and Windows.
Which Linux distributions are recommended for running IronWord in Docker?
IronWord runs smoothly on 64-bit Linux distributions such as Ubuntu 22.04+ (Jammy), Ubuntu 20.04 (Focal), Debian 11+ (Bullseye), and CentOS 7+.
How do I add IronWord to a .NET project using NuGet?
IronWord can be added to a .NET project by running the installation command in the NuGet Package Manager Console, which automatically includes the library in your project.
What is the benefit of using Microsoft's official Docker images for IronWord?
Using Microsoft's official Docker images with the .NET runtime and SDK simplifies setup and dependency management, ensuring a seamless integration with IronWord.
What are some example Dockerfiles for setting up IronWord on Ubuntu?
The page provides Dockerfile examples for Ubuntu 22 with .NET 8 and Ubuntu 20.04 with .NET 6, detailing steps from setting up the base image to running the application.
How can I set up IronWord on Debian using Docker?
An example Dockerfile for Debian 11 with .NET 7 is provided, which includes steps to build and deploy the IronWord application within a Docker container.
Is it necessary to install additional fonts for IronWord on Linux containers?
Yes, installing fonts such as fonts-liberation or ttf-mscorefonts-installer may be needed on Linux containers for proper document rendering when using IronWord.
Does IronWord support all versions of .NET?
IronWord supports .NET 5-9, .NET Standard (2.x, 3.x), and .NET Framework 4.6.2+, making it versatile for various .NET application versions.
What are the steps for deploying an IronWord application on CentOS 7?
The page outlines a Dockerfile for CentOS 7, which includes using a .NET 6 runtime, installing necessary fonts, and setting up the environment to run IronWord applications.
Why choose Docker for deploying IronWord applications?
Docker ensures that IronWord applications have a lightweight and self-contained environment, providing consistent performance across different stages of application development and deployment.