title: How do I install some default fonts to Openjdk 8 running in Docker
body: <p>I have a Docker file Java based application - <a href="https://hub.docker.com/r/songkong/songkong/~/dockerfile/" rel="nofollow noreferrer">https://hub.docker.com/r/songkong/songkong/~/dockerfile/</a></p>
  
  <p>One problem is that the DockerFile does not seem to come with any fonts installed and this causes this error for my application</p>
  
  <pre><code>java.lang.NullPointerException
      at sun.awt.FontConfiguration.getVersion(FontConfiguration.java:1264)
      at sun.awt.FontConfiguration.readFontConfigFile(FontConfiguration.java:219)
      at sun.awt.FontConfiguration.init(FontConfiguration.java:107)
      at sun.awt.X11FontManager.createFontConfiguration(X11FontManager.java:774)
      at sun.font.SunFontManager$2.run(SunFontManager.java:431)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.font.SunFontManager.&lt;init&gt;(SunFontManager.java:376)
      at sun.awt.FcFontManager.&lt;init&gt;(FcFontManager.java:35)
      at sun.awt.X11FontManager.&lt;init&gt;(X11FontManager.java:57)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
      at java.lang.Class.newInstance(Class.java:442)
      at sun.font.FontManagerFactory$1.run(FontManagerFactory.java:83)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
      at java.awt.Font.getFont2D(Font.java:491)
      at java.awt.Font.canDisplayUpTo(Font.java:2060)
      at java.awt.font.TextLayout.singleFont(TextLayout.java:470)
      at java.awt.font.TextLayout.&lt;init&gt;(TextLayout.java:531)
      at org.apache.poi.ss.util.SheetUtil.getDefaultCharWidth(SheetUtil.java:275)
      at org.apache.poi.xssf.streaming.AutoSizeColumnTracker.&lt;init&gt;(AutoSizeColumnTracker.java:117)
      at org.apache.poi.xssf.streaming.SXSSFSheet.&lt;init&gt;(SXSSFSheet.java:79)
      at org.apache.poi.xssf.streaming.SXSSFWorkbook.createAndRegisterSXSSFSheet(SXSSFWorkbook.java:656)
      at org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheet(SXSSFWorkbook.java:677)
      at org.apache.poi.xssf.streaming.SXSSFWorkbook.createSheet(SXSSFWorkbook.java:83)
      at com.jthink.songkong.reports.spreadsheet.Worksheet.&lt;init&gt;(Worksheet.java:23)
      at com.jthink.songkong.reports.spreadsheet.BasicWorksheet.&lt;init&gt;(BasicWorksheet.java:15)
      at com.jthink.songkong.reports.spreadsheet.SpreadsheetReport.&lt;init&gt;(SpreadsheetReport.java:51)
      at com.jthink.songkong.reports.fixsongsreport.SpreadsheetReportSection.outputReport(SpreadsheetReportSection.java:82)
      at com.jthink.songkong.reports.FixSongsReport.outputSpreadsheet(FixSongsReport.java:1033)
      at com.jthink.songkong.reports.FixSongsReportCreator.createReport(FixSongsReportCreator.java:122)
      at com.jthink.songkong.analyse.toplevelanalyzer.FixSongsController.start(FixSongsController.java:329)
      at com.jthink.songkong.server.callback.ServerFixSongs$Task.run(ServerFixSongs.java:448)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:748)
  </code></pre>
  
  <p>I have had this issue before on a (non Docker) linux installation, and I got round it by adding some fonts to my application download and then using</p>
  
  <pre><code>fc-cache -rv /opt/songkong/fonts
  </code></pre>
  
  <p>to install the fonts</p>
  
  <p>So I added the fonts to the application download and then added</p>
  
  <pre><code>CMD fc-cache -rv /opt/songkong/fonts;
  </code></pre>
  
  <p>to my DockerFile but it hasn't worked</p>
  
  <p>Probably this is not the correct way to do this, is there a correct way.</p>