title: Best way to install java 8 using docker?
body: <p>I have a dockerfile that starts with the following line</p>
  
  <p><code>FROM java:8</code> </p>
  
  <p>I thought this is supposed to pull the image from the docker container registry and install. no?</p>
  
  <p>when I run the java command inside my container I get the following error </p>
  
  <pre><code>ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
  </code></pre>
  
  <p>What is the easiest and the best way to install java 8(openjdk version) using docker?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <pre><code>RUN apt-get install -y --no-install-recommends software-properties-common
  RUN add-apt-repository -y ppa:openjdk-r/ppa
  RUN apt-get update
  RUN apt-get install -y openjdk-8-jdk
  RUN apt-get install -y openjdk-8-jre
  RUN update-alternatives --config java
  RUN update-alternatives --config javac
  </code></pre>