How to Install/add jdk 7 in Docker Container

Viewed 13528

I have created a docker image with Python as base in my Ubuntu 14.04 machine. Docker version I am using is 1.12.3. Base OS of Python used in image is Debian. I also require JAVA 7 (JDK 7) in my docker image. There are few Python scripts in it and also few scripts which requires JDK also.

I was able to get JDK 7 in my image but from past few days it stopped working. It is throwing error that oracle-jdk-7 package is no more available. Then I tried to get JDK 7 Dockerfile content from Dockerhub and added those lines in my dockerfile. It worked couple of times and then it started throwing error that space is not sufficient.

But space is not an issue as '/var' is only 29% occupied. Following is my Dockerfile content.

FROM python:2.7

ENV http_proxy http://http.proxy.abc.com:8000
ENV https_proxy http://http.proxy.abc.com:8000

RUN \
  apt-get update && \
  apt-get install -y openjdk-7-jdk && \
  rm -rf /var/lib/apt/lists/*

ENV JAVA_HOME /usr/lib/jvm/java-7-openjdk-amd64

RUN pip install datetime && \
pip install pandas && \
pip install xlrd && \
pip install email && \
pip install Jinja2 && \
pip install bokeh==0.12.4

And I also tried following for jdk 7:

RUN    echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee /etc/apt/sources.list.d/webupd8team-java.list && \
       echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list && \
       apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886 && \
       apt-get update -qq && \
       echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && \
       apt-get install oracle-java7-installer libxext-dev libxrender-dev libxtst-dev -y --no-install-recommends && \
       apt-get clean autoclean && \
       apt-get autoremove --yes && \
       rm -rf /var/lib/{apt,dpkg,cache,log}/ && \
      rm -rf /var/cache/oracle-jdk7-installer

This throws error that download is failed with 404 error and Oracle JDK 7 is not downloaded. This was working fine till few days back.

I tried this also.

RUN \
  apt-get update && \
  apt-get install -y openjdk-7-jdk && \
  rm -rf /var/lib/apt/lists/*

This throws error that space is full. I see that '/var' is only 29% occupied.

Tried this also.

RUN apt-get update && \
    apt-get upgrade -y && \
    apt-get install -y  software-properties-common && \
    add-apt-repository ppa:webupd8team/java -y && \
    apt-get update && \
    echo oracle-java7-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && \
    apt-get install -y oracle-java8-installer && \
    apt-get clean

This throws error that few packages are missing.

Please help me getting jdk 7 in my docker image. Any JDK type would do. Oracle JDK or open jdk.

Thanks in advance.

3 Answers
Related