Read image files in a Docker container

GemBox.Imaging is a cross-platform imaging library for .NET so you can use it inside docker containers that are running .NET Docker images. To run this example locally, you must first install Docker Desktop.

Visual Studio container tool for adding Docker to existing .NET Core project
Screenshot of Visual Studio container tool

The following code presents a project file for the .NET Core application with added Docker support.

<Project Sdk="Microsoft.NET.Sdk">


    <PackageReference Include="GemBox.Imaging" Version="*" />
    <PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="*" />


To configure or customize a Docker image, you'll need to edit the Dockerfile.

The example below shows how you can read image files from Docker containers and configure Docker images with Dockerfile.

FROM AS base

FROM AS build
COPY ["ImagingDocker.csproj", ""]
RUN dotnet restore "./ImagingDocker.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "ImagingDocker.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "ImagingDocker.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final

COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "ImagingDocker.dll"]
using GemBox.Document;

class Program
    static void Main()
        using (var image = Image.Load("FragonardReader.jpg"))
            // Display image information
            Console.WriteLine($"Image size: {image.Width}x{image.Height}");
Imports GemBox.Document

Module Program

	Sub Main()

		Using image As Image = Image.Load("FragonardReader.jpg")
			' Display image information
			Console.WriteLine($"Image size: {image.Width}x{image.Height}")
		End Using
	End Sub
End Module

See also

Next steps

GemBox.Imaging is a .NET component that provides an easy way to load, edit, save images. GemBox.Imaging also supports file format conversions and image transformations (resize, crop, rotate and flip).

Download Buy