If you need Arial or some other Microsoft “Core Fonts” in your Docker or other headless installation, you might be tempted to just copy the fonts from your Windows installation, check them into your source control, and then copy it from there into the container, but reading the official Microsoft font FAQ and probably also somewhere buried in the EULA or font license, it’s not allowed to redistribute the font.
Web searches will quickly point you to the
ttf-mscorefonts-installer packages, but only the later is actually available on Debian or Ubuntu. The issue here is, that the package just runs a post install script that requires you to accept the Microsoft EULA and only then downloads the fonts. So, if you’re in a headless environment, like when building a Docker image, you can’t really accept the EULA on the fly.
After a bit of web searching, I did eventually find an AskUbuntu answer that solved the issue for me:
DEBIAN_FRONTEND noninteractive echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | debconf-set-selections apt-get update && apt-get install -y --no-install-recommends ttf-mscorefonts-installer
Don’t forget to update the font cache afterwards!
All combined in a Dockerfile could look something like this:
ENV DEBIAN_FRONTEND=noninteractive RUN echo "ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true" | debconf-set-selections RUN apt-get update \ && apt-get -y install --no-install-recommends \ ttf-mscorefonts-installer RUN fc-cache -fv
You can also use
fc-list to check which fonts are available. If the fonts were installed correctly,
ls /usr/share/fonts/truetype/msttcorefonts should not return an empty directory with just a README file.
Be extra careful if you’re using some sort of caching, as the fonts might not get cached properly and end up missing.
The reason this is probably, most likely not in violation of any terms, is because it’s using the official font archives, so technically Microsoft is redistributing their own fonts.