Unable to load shared library quot;libgdiplusquot; - Docker [ .NET application with Aspose API](无法加载共享库“libgdiplus- Docker [带有 Aspose API 的 .NET 应用程序])
问题描述
当我创建一个用于部署的 docker 文件时,该应用程序通常在开发环境中工作,它因 libgdiplus 问题而失败.
The application is normally working with development environment when i create a docker file for deployment it getting failed with libgdiplus issue.
DockerFile
FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS base
WORKDIR /app
FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build
RUN apt-get update && apt-get install -y apt-utils
RUN apt-get install -y libfontconfig1
RUN apt-get install -y libgdiplus
RUN apt-get install -y libc6-dev
RUN ln -s /usr/lib/libgdiplus.so/usr/lib/gdiplus.dll
# copy csproj and restore as distinct layers
WORKDIR /src
COPY HelloWorld/HelloWorld.csproj HelloWorld/
RUN dotnet restore HelloWorld/HelloWorld.csproj
COPY . .
WORKDIR /src/HelloWorld
RUN dotnet build HelloWorld.csproj -c Release -o /app
FROM build AS publish
RUN dotnet publish HelloWorld.csproj -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "HelloWorld.dll"]
即使我尝试了以下脚本来加载库,但仍然失败
RUN apt-get update
&& apt-get install -y --allow-unauthenticated
libc6-dev
libgdiplus
libx11-dev
&& rm -rf /var/lib/apt/lists/*
错误
Connection id "0HLRJJEGNBH3R", Request id "0HLRJJEGNBH3R:00000001": An unhandled exception was thrown by the application.
Aspose.Slides.PptxReadException: The type initializer for 'Gdip' threw an exception.
---> System.TypeInitializationException: The type initializer for 'Gdip' threw an exception.
---> System.DllNotFoundException: Unable to load shared library 'libgdiplus' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibgdiplus: cannot open shared object file: No such file or directory
at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output)
推荐答案
您在构建容器映像中安装 libgdiplus,但不是在最终容器映像中.您需要确保 libgdiplus 已安装在您的最终容器映像中.
You're installing libgdiplus in your build container image, but not in your final container image. You need to make sure libgdiplus is installed in your final container image.
您可以考虑像这样修改您的 Dockerfile:
You can consider amending your Dockerfile like this:
FROM mcr.microsoft.com/dotnet/core/aspnet:3.0 AS base
RUN apt-get update && apt-get install -y libgdiplus
WORKDIR /app
FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build
[...]
这篇关于无法加载共享库“libgdiplus"- Docker [带有 Aspose API 的 .NET 应用程序]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:无法加载共享库“libgdiplus"- Docker [带有 Aspose API 的 .NET 应用程序]
- Azure Active Directory 与 MVC,客户端和资源标识同一 2022-01-01
- 带问号的 nvarchar 列结果 2022-01-01
- 在 LINQ to SQL 中使用 contains() 2022-01-01
- Windows 喜欢在 LINUX 中使用 MONO 进行服务开发? 2022-01-01
- 在 C# 中异步处理项目队列 2022-01-01
- 是否可以在 .Net 3.5 中进行通用控件? 2022-01-01
- 使用 rss + c# 2022-01-01
- 为什么 C# 中的堆栈大小正好是 1 MB? 2022-01-01
- CanBeNull和ReSharper-将其用于异步任务? 2022-01-01
- C# 通过连接字符串检索正确的 DbConnection 对象 2022-01-01