我正在尝试在运行 Ubuntu 18.04 的 docker 容器中安装字体(Dockerfile 继承自 Jupyter scipy 笔记本,该笔记本继承自基本 jupyter 映像,此处为Dockerfile )。
我尝试了很多不同的东西,包括这个答案和那里的其他建议。
我的 Dockerfile 看起来像
FROM jupyter/scipy-notebook
USER root
# bash instead of dash to use source
RUN ln -snf /bin/bash /bin/sh
# These require sudo so they must come before defining
# a user
# Font attempt
COPY GillSansMTPro-Medium.otf /usr/local/share/fonts
RUN fc-cache -f -v
# installing some pip packages
Run Code Online (Sandbox Code Playgroud)
当我尝试在 matplotlib 中使用这种字体时,我看到了这个错误:

我试过添加
RUN rm -fr ~/.cache/matplotlib
Run Code Online (Sandbox Code Playgroud)
到我的 Dockerfile(在上面显示的部分之后),因为我在网上阅读可以解决问题。它也没有用。
此外,如果我导航到/usr/local/share/fonts,字体会按预期出现。
任何想法如何解决这个问题?