-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't use System.Drawing.Common in microsoft/dotnet:runtime #618
Comments
It turns out that I couldn't add that library from windows machine (where I was trying to build the container). After I pushed the Dockerfile out to a linux build agent, it was able to add the library and build properly. This causes some problem because I can't build the container the locally for development purposes but I can work around that for now. |
@sddev-dotnet - Hmm, sounds like the underlying issue was an intermittent issue with the apt feed you are using to pull from. Try it again on your Windows machine. I just tried a Bitmap sample app and everything worked as expected from both a Windows and Linux Docker host. FYI - I was using the microsoft/dotnet:2.1-sdk image which is based on Debian Stretch. One tip regarding the pattern used to install the apt packages. Make sure you cleanup the apt cache within your Dockerfile as this bloats the resulting image. It is a Docker best practice.
|
Closing but feel free to continue the conversation. |
I am having the same problem. I am trying to run tests in a GitLab CI task using the @MichaelSimons do I understand you correctly that this is working for you without building your own Docker image? |
@jugglingthebits - No, the microsoft/dotnet images do not contain the native
|
@MichaelSimons Thanks for the workaround! IMHO this is a bug in the docker image though, why did you close this? |
The runtime Dockerfiles only install the core dependencies. There are additional dependencies that are required for non-mainline scenarios that are not included by default such as |
Ah ok, tradeoffs :-) Just my 2 cents, it would have helped me if there was documentation referenced from https://hub.docker.com/r/microsoft/dotnet/ where "non-mainline" apis were listed together with the packages required to enable them. |
@jugglingthebits - That is a good suggestion. Would you mind logging a new issue specific to documenting these non-mainline scenarios? Please reference this issue. Thanks for the feedback! |
This is my Dockerfile:
|
Hi! "Unable to load shared library 'kernel32.dll or one of its dependencies. In order to help diagnose problems, consider setting the LD_DEBUG enviroment variable: kernel32.dll: cannot open shared file: no such file or directory." |
@MaitePerez - Please upgrade to .NET 2.1 or newer. 2.0 is EOL and no longer supported. I'm sure you will got more support once you upgrade to a supported version. |
@MichaelSimons Thank you so much for the replay. I'm actually using net core 2.1 and net and net standar 2.0, sorry for the confusión. |
For alpine dotnet runtime, add additional repository RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && apk update && apk add --no-cache libgdiplus |
Quick confirmation here.
to have it working on |
I added the install of libgdiplus, but I still get this runtime error. Am I missing something from my Dockerfile? I'm on windows but docker set to linux containers.
|
For microsoft/dotnet:3.0-runtime-alpine |
Make sure you install it in your runtime and not in your dotnet build. e.g. here is my solution
|
@jbdhacf Thanks! |
With microsoft/dotnet:2.2-aspnetcore-runtime still have similar problems.
Unable to load shared library 'user32.dll' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libuser32.dll: cannot open shared object file: No such file or directory |
Were you able to move past this issue? |
For folks as noobish about Docker as I am, make sure that these changes (which worked for me - thanks!) get put in the LAST layer of your dockerfile. The provided code shows that clearly in the FROM statement, but I didn't notice that at first and added this stuff in my build layer, which of course was useless. |
@Dangelo123 May I ask which PDF lib you did end up with? |
Back in dotnetcore 2.2, I had to use this process to add all of the necessary libraries to my container so that it would work with system.drawing. This may have to be updated for 3.1. I'm actually working on this today for 3.1 so ill provide any updated instructions as I find them:
|
The steps for adding the required components to use System.Drawing is also documented in the Using the System.Drawing.Common Package in a Docker Container snippet. |
What library did you end up using? |
@Denny966 I gave up finding a decent netcore PDF library Ended up, satisfied, using https://github.com/thecodingmachine/gotenberg |
okay after reading and trying all these different apt-gets and whatnot, to get system.drawing.common to work in blazor server side with .NET Core 3.1 it was as simple as this:
|
So which library you ended up picking? |
It happens the same for NET 5 with Google.Cloud.Firestore nuget package in a
|
Hi guys, I have the issue with libgdiplus which on windows containers. FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base WORKDIR /app FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build COPY . . FROM build AS publish FROM build AS final |
@eric10220420 - See #1098. The easiest solution is to use Windows Server Core instead of Nano Server. We do now offer a tag for Windows Server Core 2019: |
What you means is only change the first line to: Right? Thanks. |
@eric10220420 - I would also use it for the build stage as well to take advantage of layer sharing: - FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
+ FROM mcr.microsoft.com/dotnet/sdk:5.0-windowsservercore-ltsc2019 AS build There should not be anything else necessary. The use of chocolatey in the other issue was to install .NET and isn't relevant here since .NET is in the If you're still experiencing application issues using the |
try with this solution but not working! My captcha still stuck with this exception: "DllNotFoundException: Unable to load DLL 'gdiplus.dll' or one of its dependencies: The specified module could not be found." |
@cuongvu0203 - Can you share your Dockerfile? |
My dockerfile: #Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed. FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base FROM mcr.microsoft.com/dotnet/sdk:5.0-windowsservercore-ltsc2019 AS build FROM build AS publish FROM base AS final |
@cuongvu0203 - It looks like you're only using Windows Server Core in the build stage. There is no dependency on gdiplus.dll in that stage because the app isn't being run there, it's only being built. The key is your first |
How do you install the dependencies on RHEL using yum? I can't figure it out. :( |
I had the same issue, I was using Windows and my docker threw same exceptions. I could not add those dependencies that System.Drawing. There is a great blog from Scott Hanselman - https://www.hanselman.com/blog/how-do-you-use-systemdrawing-in-net-core I removed the references for System.Drawing and started using ImageSharp. This works fine now. For anybody looking here, use https://github.com/SixLabors/ImageSharp instead of system drawing. That definitely helps |
Steps to reproduce the issue
Expected behavior
Should be able to create thumbnail images using the Bitmap class from System.Drawing.Common
Actual behavior
Get error:
System.TypeInitializationException: The type initializer for 'Gdip' threw an exception. ---> System.DllNotFoundException: Unable to load shared library 'libdl' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibdl: cannot open shared object file: No such file or directory
Additional information (e.g. issue happens only occasionally)
A little research says we need to install libgdiplus and libc6-dev. I used the following to attempt that:
That fails with errors about hashes not matching or size being greater than expected
Output of
docker version
Output of
docker info
The text was updated successfully, but these errors were encountered: