无法装入共享库'libldap-2.4.so.2'或其依赖项之一



团队,

我在docker上运行时遇到以下错误。它在windows机器上运行良好-

无法加载共享库"libldap-2.4.so.2"或其某个依赖关系。为了帮助诊断加载问题,请考虑设置LD_DEBUG环境变量:liblibldap-2.4.so.2:无法打开共享对象文件:没有这样的文件或目录

我正在使用系统。目录服务。LdapConnection的协议命名空间。已经尝试在我的docker映像中安装libldap。以下三种方式,但都不起作用。

RUN apt-get update && apt-get install libldap-2.4-2

RUN apt-get update 
&& apt-get install -y --no-install-recommends 
libldap-2.4-2 
&& rm -rf /var/lib/apt/lists/*
RUN apk add libldap

这是我的案卷

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
RUN apt-get update 
&& apt-get install -y --no-install-recommends 
libldap-2.4-2 
&& rm -rf /var/lib/apt/lists/*
WORKDIR /src
COPY ["Ldaptest1/Ldaptest1.csproj", "Ldaptest1/"]
RUN dotnet restore "Ldaptest1/Ldaptest1.csproj"
COPY . .
WORKDIR "/src/Ldaptest1"
RUN dotnet build "Ldaptest1.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Ldaptest1.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Ldaptest1.dll"]

我目前正在使用。NET 6,并且在初始化LdapConnection-时在下面的行中中断

var connection = new LdapConnection(ldapDomain)

我经历了这一切——https://github.com/dotnet/dotnet-docker/issues/1946.但这无济于事。

提前感谢

将安装命令移动到上一个FROM之后,这应该会修复它。

我不得不这么做。NET Core 5镜像,它工作了。

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["Ldaptest1/Ldaptest1.csproj", "Ldaptest1/"]
RUN dotnet restore "Ldaptest1/Ldaptest1.csproj"
COPY . .
WORKDIR "/src/Ldaptest1"
RUN dotnet build "Ldaptest1.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Ldaptest1.csproj" -c Release -o /app/publish
FROM base AS final
RUN apt-get update 
&& apt-get install -y --no-install-recommends 
libldap-2.4-2 
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Ldaptest1.dll"]

相关内容

  • 没有找到相关文章