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.
Your environment contains a proxy definition
ENV http_proxy http://http.proxy.abc.com:8000
ENV https_proxy http://http.proxy.abc.com:8000
with that, all traffic to the outside is routed to a non-existent location. Remove these lines and docker will be able to retrieve the apt resources.
So apart from that, I'll give you the full dockerfile here:
FROM python:2.7-wheezy
RUN pip install datetime && \
pip install pandas && \
pip install xlrd && \
pip install email && \
pip install Jinja2 && \
pip install bokeh==0.12.4
# add webupd8 repository
RUN \
echo "===> add webupd8 repository..." && \
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list && \
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list && \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886 && \
apt-get update && \
\
\
echo "===> install Java" && \
echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes oracle-java8-installer oracle-java8-set-default && \
\
\
echo "===> clean up..." && \
rm -rf /var/cache/oracle-jdk8-installer && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
Build it:
$ docker build -t t .
It results after being built in the following:
$ docker run t java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
$ docker run t python -V
Python 2.7.13
Update: If you want to use oracle jdk7 simply exchange the code that installs the jdk within the dockerfile by the following. Also note that I'd prefer to keep two different jdks in different docker containers at all. It is way better to reference the needed java version from a different image, just name your builds after the content they have, like: docker build -t py27jdk7
# add webupd8 repository
RUN \
echo "===> add webupd8 repository..." && \
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list && \
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list && \
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886 && \
apt-get update && \
\
\
echo "===> install Java" && \
echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --force-yes oracle-java7-installer oracle-java7-set-default && \
\
\
echo "===> clean up..." && \
rm -rf /var/cache/oracle-jdk7-installer && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
Dockerfile was partly taken from here.
Most likely this is because the layers where the apt-get update
was done are cached, and became old.
So, tell docker to RUN again the apt-get update
and discard the cached one. Just add --no-cache
to your docker build
command:
docker build --no-cache ....
Or, if you are using docker-compose
:
docker-compose build --no-cache ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With