Reputation: 1442
We are running a .Net core console application on a windows container with Kubernetes (Amazon EKS). The host OS is Windows Sever 2016. Getting the below error when a excel file is generated by Aspose.Cells.
System.TypeInitializationException: The type initializer for 'Gdip' threw an exception. --->
System.DllNotFoundException: Unable to load DLL 'gdiplus.dll' or one of its dependencies:
The specified module could not be found.
As suggested in this link, tried using the windows image so that GDI library will be available in the container but it didn't work. Below is the docker file ,
FROM mcr.microsoft.com/windows:1809
FROM mcr.microsoft.com/dotnet/runtime:5.0
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
COPY ./ /App/WS
WORKDIR /App/WS
ENTRYPOINT ["dotnet", "AppService.dll"]
Tried with below images as well, but no luck.
FROM mcr.microsoft.com/dotnet/aspnet:5.0
FROM mcr.microsoft.com/dotnet/sdk:5.0
and
FROM mcr.microsoft.com/windows/servercore:ltsc2019
FROM mcr.microsoft.com/dotnet/runtime:5.0
There are options for linux containers to explicitly install gdiPlus library, couldn't find anything like that for windows containers. At present we are looking to deploy our application only on windows containers. Appreciate any help!
Upvotes: 0
Views: 2703
Reputation: 3995
By default, the 5.0
tag gives you Windows Nano Server when targeting Windows containers. This SKU of Windows is trimmed down and does not contain gdiplus.dll. What you would want instead is Windows Server Core which does have that DLL. This is documented here: https://github.com/dotnet/dotnet-docker/blob/main/documentation/scenarios/using-system-drawing-common.md.
Based on the other tags I see you referencing, it seems that you're targeting Windows Server 2019 to use for your container. Luckily, .NET does provide .NET 5.0 images for Windows Server Core 2019. The tag to use for that is 5.0-windowsservercore-ltsc2019
. You can find this listed at https://hub.docker.com/_/microsoft-dotnet-runtime. That would be the recommended tag to use to resolve this issue.
I question whether you're actually using Windows Server 2016 as a host environment. No version of Windows Server is capable of running containers using a Windows version newer than the host version. This Windows container version compatibility matrix is described here: https://learn.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility?tabs=windows-server-2016%2Cwindows-10-20H2.
I'm also a little confused by the content of your Dockerfile because you keep listing two successive FROM
instructions. For example, you posted this:
FROM mcr.microsoft.com/windows:1809
FROM mcr.microsoft.com/dotnet/runtime:5.0
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
COPY ./ /App/WS
WORKDIR /App/WS
ENTRYPOINT ["dotnet", "AppService.dll"]
The first FROM
instruction has no impact on the resulting image. The mcr.microsoft.com/windows:1809
base isn't used at all in the image that gets output because you have a subsequent FROM
instruction right after it. It seems like you're trying to pull down the mcr.microsoft.com/windows:1809
image to use as the base for the mcr.microsoft.com/dotnet/runtime:5.0
image but that's not how it works. I would encourage you to read up on Dockerfile structure. You may also be interested in learning about ways to install .NET onto other image types for which .NET doesn't provide official images for. That kinda seems like what you were trying to do here. But there is official guidance on how this can be done at https://github.com/dotnet/dotnet-docker/blob/main/documentation/scenarios/installing-dotnet.md. Basically, you would use a base image just as you had done with mcr.microsoft.com/windows:1809
and explicitly install .NET from its zip file.
Upvotes: 1