Read image files in Docker container
GemBox.Imaging can be used inside docker containers that are running .NET Docker images.
To use Docker, you must first install Docker Desktop. After that, you can containerize your .NET application.

The following code presents a project file for the .NET Core application with added Docker support.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>.</DockerfileContext>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GemBox.Imaging" Version="*" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="*" />
</ItemGroup>
</Project>
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 mcr.microsoft.com/dotnet/runtime:7.0 AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
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
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "ImagingDocker.dll"]
using GemBox.Document;
class Program
{
static void Main()
{
ComponentInfo.SetLicense("FREE-LIMITED-KEY");
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()
ComponentInfo.SetLicense("FREE-LIMITED-KEY")
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
Published: September 21, 2022 | Modified: December 20, 2022 | Author: Ercan Görgülü