'How to install fonts in Docker Windows Container?

I'm trying to install a font in a docker windows container based on 4.8-windowsservercore-ltsc2019 image. I found some solutions but none of them worked for me.

I created a github project that reproduces my problem.

https://github.com/AndySchmitt/docker-font-windows-ltsc2019

This is a simple C# Api project that uses wkhtmltopdf to create a PDF file. When you run without docker, it generates a pdf file with Arial font. When you run within docker, it generates the same pdf, but with another font.

In this windows container, Microsoft deleted all fonts from the fonts folder, and I'm having problem installing new fonts to this image.

My question is: How can I generate the pdf using Arial font inside docker container? Or, how can I install Arial font in this windows image and make wkhtmltopdf use this recently intalled font?



Solution 1:[1]

In your Dockerfile is this:

...
COPY /bin/Resources/FontInstall.ps1 c:/windows/fonts/
ARG CACHEBUSTER=7
WORKDIR /Windows/Fonts

RUN ["powershell.exe", "C:\\Inetpub\\wwwroot\\Fonts\\FontInstall.ps1"]

When you copy your script to c:/windows/fonts/, should it not also been run from this directory (last line)?

I think it needs to be changed to:

RUN ["powershell.exe", "C:\\Windows\\Fonts\\FontInstall.ps1"]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1