Search code examples
docker.net-corewkhtmltopdf

Unable to load native library. The platform may be missing native dependencies (libjpeg62, etc). Or the current platform is not supported


I am having this error Unable to load native library. The platform may be missing native dependencies (libjpeg62, etc). Or the current platform is not supported from my docker image running .Net Core 6

My docker install for Wkhtml dependencies looks like this;


RUN apt-get update -qq 

RUN apt-get install -y fontconfig fontconfig-config fonts-dejavu-core libbsd0 \
libfontconfig1 libfontenc1 libfreetype6 libjpeg62-turbo libmd0 libpng16-16 \
libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6 libxrender1 sensible-utils \
ucf x11-common xfonts-75dpi xfonts-base xfonts-encodings xfonts-utils libgdiplus libc6-dev


RUN apt-get -qy install --no-install-recommends wget
RUN wget -nv -O /tmp/wkhtmltox.deb https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.bullseye_amd64.deb
RUN apt-get -qy install /tmp/wkhtmltox.deb


RUN cp /usr/local/bin/wkhtmltopdf /usr/bin
RUN cp /usr/local/bin/wkhtmltoimage /usr/bin


RUN  wget http://ftp.osuosl.org/pub/ubuntu/pool/universe/libj/libjpeg6b/libjpeg62_6b2-3_amd64.deb

RUN apt-get -y autoremove libjpeg62-turbo

RUN dpkg -i libjpeg62_6b2-3_amd64.deb

RUN apt --fix-broken install


As you can See I am even uninstalling libjpeg62-turbo and instead installing the older libjpeg62

NOTE

I am using microsofts image : FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base which is a debian based image

I am stuck and I don't know how to fix this problem, hoping I can get assisted with this issue.


Solution

  • I had the same trouble, actually, the solution is here https://stackoverflow.com/a/70414848/19536096

    I've just replaced this line

    FROM mcr.microsoft.com/dotnet/aspnet:6.0.1-bullseye-slim AS base
    

    for

    FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
    

    And this line

    FROM mcr.microsoft.com/dotnet/sdk:6.0.1 AS build
    

    for

    FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
    

    Test it, and let me know if works for you as well.