title: How to install multiple openjdk versions on alpine-based docker container
body: <p>I wish to install jdk7 and jdk8 on an alpine container side by side. I would like to pick jdk7 only if an env variable is set.</p>
  
  <p>I've chained <code>FROM openjdk:7-alpine</code> and <code>FROM openjdk:8-alpine</code>, but regardless of their relative order, the latter one overwrites the former. So, I am left with only 1 installation as seen in <code>'/usr/lib/jvm'</code>.</p>
  
  <p><strong>Why I need this:</strong></p>
  
  <p>I need this setup for a slave container for Jenkins. Now, jenkins remoting jar runs ONLY on jdk8 now. So, I need it. Plus, since I am spawning this container for a project which needs jdk7 as default jdk, I need that too.</p>
  
  <p><strong>My Dockerfile:</strong> <a href="https://github.com/ankurshashcode/docker-slave/blob/alpine/Dockerfile" rel="noreferrer">https://github.com/ankurshashcode/docker-slave/blob/alpine/Dockerfile</a></p>