title: Why is the Java 11 base Docker image so large? (openjdk:11-jre-slim)
body: <p>Java 11 is announced to be the most recent LTS version. So, we're trying to start new services based on this Java version.</p>
  
  <p>However, the base Docker image for Java 11 is much larger than the equivalent  for Java 8:</p>
  
  <ul>
  <li><p><a href="https://github.com/docker-library/openjdk/blob/master/8/jre/alpine/Dockerfile" rel="noreferrer"><code>openjdk:8-jre-alpine</code></a>: 84 MB</p></li>
  <li><p><a href="https://github.com/docker-library/openjdk/blob/master/11/jre/slim/Dockerfile" rel="noreferrer"><code>openjdk:11-jre-slim</code></a>: <strong>283</strong> MB</p></li>
  </ul>
  
  <p>(I'm considering only the <a href="https://hub.docker.com/_/openjdk/" rel="noreferrer"><strong><em>official OpenJDK</em></strong></a> and <strong><em>the most lightweight</em></strong> images for each Java version.)</p>
  
  <p>Deeper digging uncovered the following "things":</p>
  
  <ul>
  <li><p>the <a href="https://github.com/docker-library/openjdk/blob/master/11/jre/slim/Dockerfile" rel="noreferrer"><code>openjdk:11-jre-slim</code></a> image uses the base image <code>debian:sid-slim</code>. This brings 2 issues: </p>
  
  <ul>
  <li><p>this is 60 MB larger than <code>alpine:3.8</code></p></li>
  <li><p>the <a href="https://www.debian.org/releases/sid/" rel="noreferrer">Debian <code>sid</code></a> versions are unstable</p></li>
  </ul></li>
  <li><p>the <code>openjdk-11-jre-headless</code> package installed in the image is <strong>3 times larger</strong> than <code>openjdk8-jre</code> (inside running Docker container):</p>
  
  <ul>
  <li><p><code>openjdk:8-jre-alpine</code>: </p>
  
  <blockquote>
  <pre><code>/ # du -hs /usr/lib/jvm/java-1.8-openjdk/jre/lib/
  57.5M   /usr/lib/jvm/java-1.8-openjdk/jre/lib/
  </code></pre>
  </blockquote></li>
  <li><p><code>openjdk:11-jre-slim</code>:</p>
  
  <blockquote>
  <pre><code># du -sh /usr/lib/jvm/java-11-openjdk-amd64/lib/
  179M    /usr/lib/jvm/java-11-openjdk-amd64/lib/
  </code></pre>
  </blockquote>
  
  <p>Going deeper I discovered the "root" of this heaviness - it's the <code>modules</code> file of the JDK:</p>
  
  <blockquote>
  <pre><code># ls -lhG /usr/lib/jvm/java-11-openjdk-amd64/lib/modules
  135M    /usr/lib/jvm/java-11-openjdk-amd64/lib/modules
  </code></pre>
  </blockquote></li>
  </ul></li>
  </ul>
  
  <p>So, now the questions which came:</p>
  
  <ul>
  <li><p>Why is <code>alpine</code> not used any more as a base image for Java 11 slim images?</p></li>
  <li><p>Why is the unstable <em>sid</em> version used for LTS Java images?</p></li>
  <li><p>Why is the slim/headless/JRE package for OpenJDK 11 so large compared to the similar OpenJDK 8 package? </p>
  
  <ul>
  <li>What is this <em>modules</em> file which brings 135 MB in OpenJDK 11?</li>
  </ul></li>
  </ul>
  
  <p><strong>UPD</strong>: as a solutions for these challenges one could use this answer: <a href="https://stackoverflow.com/questions/53669151/java-11-application-as-docker-image/53669152#53669152">Java 11 application as docker image</a></p>