6

I have a console application that is built on .NET Framework v4.8. I am trying to run it in Azure Container Instances(ACI) using the docker image. I have created a docker image locally and pushed it to ACI and it is running successfully.

Now I am facing one issue. This application sends an email with RDLC reports. But the reports I am getting in the mail have different fonts than the report I am getting previously(without docker). I found that the base docker image mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019 I am using does not have fonts loaded with it. I need to install fonts in my docker image/container. How can I do this?

Below is my Dockerfile commands:

FROM mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019  AS BASE
COPY . .
ENTRYPOINT BackgroundService.exe
Lin Du
  • 88,126
  • 95
  • 281
  • 483
Abhishek Prajapati
  • 345
  • 1
  • 4
  • 15

2 Answers2

5

I have done some investigation and found a way to add fonts to the container using Dockerfile. We need to below line docker file:

COPY arial*.ttf c:/windows/fonts/

Below is the updated Dockerfile:

# app image
FROM mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019  AS BASE
COPY arial*.ttf c:/windows/fonts/
COPY . .
ENTRYPOINT BackgroundService.exe
Abhishek Prajapati
  • 345
  • 1
  • 4
  • 15
0

In case we only need to add fonts to the container and not to the image, the following solution may help:

docker run -dit --name "my-chromium-agent" my-agent-image:latest `
  -v C:\Windows\Fonts:C:\Windows\Fonts

NOTE: Directly mounting the Fonts folder of the local system into the container may implicate security risk.

In case you have the following error using Chromium on Windows servercore 1909 docker image, the above solution will help:

15 09 2021 08:54:11.665:INFO [launcher]: Starting browser Chrome 15 09 2021 08:54:12.400:ERROR [launcher]: Cannot start Chrome [0915/085411.853:ERROR:network_change_notifier_win.cc(228)] WSALookupServiceBegin failed with: 0

DevTools listening on ws://127.0.0.1:9222/devtools/browser/46bdbf30-8381-473a-9816-a5ad56f9c71a [0915/085411.978:ERROR:platform_font_skia.cc(344)] Could not find any font: Segoe UI, sans. Falling back to the default

It may also important to note the following sentence in the documentation (link):

If you only copy the font into the %windir%\fonts folder, the font will be available only after the system is rebooted.

minus one
  • 642
  • 1
  • 7
  • 28