title: Installing Java in Docker image
body: <p>This is my very first try to create a Docker image and I'm hoping someone can help me out. My Dockerfile looks roughly like this:</p>
  <pre><code>FROM mybaseimage:0.1
  MAINTAINER ...
  
  ENV JAVA_HOME /usr/lib/jvm/java-7-openjdk-amd64
  RUN sed 's/main$/main universe/' -i /etc/apt/sources.list
  
  ENV DEBIAN_FRONTEND noninteractive
  
  RUN apt-get update
  
  RUN apt-get install -y openjdk-7-jre &amp;&amp; apt-get clean &amp;&amp;\
               mkdir temp_dir  &amp;&amp;   cd temp_dir &amp;&amp; \
               ${JAVA_HOME}/bin/jar -xvf somejar.jar  &amp;&amp;\
               cd ..
  ENTRYPOINT [&quot;somescript.sh&quot;]
  </code></pre>
  <p>Basically I'm only installing Java so I can expand a jar file. When I run my makefile I get the following error:</p>
  <p>/bin/sh: 1: /usr/lib/jvm/java-7-openjdk-amd64: Permission denied</p>
  <p>I've been trying to follow this example:
  <a href="https://registry.hub.docker.com/u/barnybug/openjdk-7-jre/dockerfile/" rel="noreferrer">https://registry.hub.docker.com/u/barnybug/openjdk-7-jre/dockerfile/</a></p>
  <p>Edit: per request in the comment here is my makefile:</p>
  <pre><code>DOCKER_REGISTRY=registry.mycompany.com
  DOCKER_IMAGE=appimage-myapp
  DOCKER_TAG=3.0
  
  SUDO=
  
  ARCHIVE_NAME=$(DOCKER_IMAGE):$(DOCKER_TAG)
    REPO_ARCHIVE_NAME=$(DOCKER_REGISTRY)/$(ARCHIVE_NAME)
    BASE_IMAGE_ARCHIVE=$(DOCKER_IMAGE)_$(DOCKER_TAG).tar.gz
  
  all: $(BASE_IMAGE_ARCHIVE)
  
  .PHONY: docker_image
  
  docker_image: Dockerfile
      $(SUDO) docker build -t $(ARCHIVE_NAME) .
  
  $(BASE_IMAGE_ARCHIVE): docker_image
    $(SUDO) docker tag -f $(ARCHIVE_NAME) $(REPO_ARCHIVE_NAME)
    $(SUDO) docker push $(REPO_ARCHIVE_NAME)
    $(SUDO) docker save $(ARCHIVE_NAME) | gzip -c &gt; $@
    $(SUDO) docker rmi $(REPO_ARCHIVE_NAME)
  </code></pre>
  <p>which I run with</p>
  <pre><code>make docker_image SUDO=sudo
  </code></pre>