I currently have a docker container with an Ubuntu(17.10) image installed with other packages included. However, I'm currently having difficulty trying to install Java onto this container in addition to the current image.
Current Dockerfile :
FROM cityofzion/neo-privatenet
ADD files/ files/
ENTRYPOINT [ "/bin/bash" ]
When trying to find information on how to do this and testing inside of the container most suggest using this command: apt-get install -y oracle-java9-installer
However this results in:E: Unable to locate package oracle-java9-installer
I have also tried this suggested command wget http://download.java.net/java/GA/jdk9/9/binaries/jdk-9+181_linux-x64_bin.tar.gz
Which produces this result HTTP request sent, awaiting response...
404 Not Found - ERROR 404: Not Found.
I have only tried running these commands in the container, since that is how they would be run and they seem to be failing.
Can anyone suggest what I can include into my Dockerfile that install java onto my image?
Thanks in advance.
You can also directly pull any of the open-jdk images mentioned at (https://hub.docker.com/_/openjdk/) and use it. There is no need to install Ubuntu in docker image and then install Java on top of it. These images already use Ubuntu (with bare-minimum file system).
add to to your docker file
RUN \
apt-get update && \
apt-get install -y software-properties-common && \
echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
add-apt-repository -y ppa:webupd8team/java && \
apt-get update && \
apt-get install -y oracle-java9-installer && \
rm -rf /var/lib/apt/lists/* && \
rm -rf /var/cache/oracle-jdk8-installer
ENV JAVA_HOME /usr/lib/jvm/java-9-oracle
Following from here
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
Oracle JDK version 7
sudo apt-get install oracle-java7-installer
Oracle JDK version 8
sudo apt-get install oracle-java8-installer
Related
I'm trying to install java on my docker to be able to use a node module (... yes ...)
I've been searching and I found multiple way of doing it but it always throw an error so, I'm gonna show you what I use for now
RUN apt-get update
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
switching grom java 8 to java 11 throw the same error:
W: The repository 'http://ppa.launchpad.net/openjdk-r/ppa/ubuntu impish Release' does not have a Release file.
E: Failed to fetch http://ppa.launchpad.net/openjdk-r/ppa/ubuntu/dists/impish/main/binary-amd64/Packages 404 Not Found
E: Some index files failed to download. They have been ignored, or old ones used instead.
If someone could help me understand what I'm missing that could be cool !
This is a way to stop the problem. The reason why I why trying to use this RUN add-apt-repository -y ppa:openjdk-r/ppa is because without I was getting this error
E: Sub-process /usr/bin/dpkg returned an error code (1)
But after some research I found this way of using java inside my docker:
RUN apt-get -y update
RUN mkdir -p /usr/share/man/man1/
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
The second line fixed the problem by creating the right folder
Hi i need to build python:3.7-slim-stretch docker image with java
Here my Dockerfile :
FROM python:3.7-slim-stretch
# Install OpenJDK-8
RUN apt-get update && \
apt-get install -y openjdk-8-jdk && \
apt-get install -y ant && \
apt-get clean;
# Fix certificate issues
RUN apt-get update && \
apt-get install ca-certificates-java && \
apt-get clean && \
update-ca-certificates -f;
# Setup JAVA_HOME -- useful for docker commandline
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
RUN export JAVA_HOME
But i'm getting this error when i build it :
...
update-alternatives: error: error creating symbolic link '/usr/share/man/man1/rmid.1.gz.dpkg-tmp': No such file or directory
dpkg: error processing package openjdk-8-jre-headless:amd64 (--configure):
subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of ca-certificates-java:
dpkg: error processing package openjdk-8-jdk:amd64 (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of openjdk-8-jre:amd64:
openjdk-8-jre:amd64 depends on openjdk-8-jre-headless (= 8u232-b09-1~deb9u1); however:
Package openjdk-8-jre-headless:amd64 is not configured yet.
E: Sub-process /usr/bin/dpkg returned an error code (1)
The command '/bin/sh -c apt-get update && apt-get install -y openjdk-8-jdk && apt-get install -y ant && apt-get clean;' returned a non-zero code: 100
Any idea ?
Thanks
add this to your dockerfile before insatll :
RUN mkdir -p /usr/share/man/man1/
you may also remove RUN export JAVA_HOME since it has no effect in Dockerfile
I have a circleci build that uses python:3.6.6-stretch. most of my services uses python, but I also need java10 + maven.
Now it seems impossible to install java10 inside python3 docker.
What is the best approach to have a docker that will support python and java ?
Java 10 is not supported anymore and is removed from most of the PPAs. Do not use it if possible.
But if you still need specifically Java 10 you can take a look how it is installed on top of an Ubuntu image by AdoptOpenJDK project.
Your Dockerfile might look somewhat like this:
FROM python:3.6.6-stretch
RUN rm -rf /var/lib/apt/lists/* && apt-get clean && apt-get update && apt-get upgrade -y \
&& apt-get install -y --no-install-recommends curl \
&& rm -rf /var/lib/apt/lists/*
RUN set -eux; \
curl -Lso /tmp/openjdk.tar.gz https://github.com/AdoptOpenJDK/openjdk10-releases/releases/download/jdk-10.0.2%2B13/OpenJDK10_x64_Linux_jdk-10.0.2%2B13.tar.gz; \
mkdir -p /opt/java/openjdk; \
cd /opt/java/openjdk; \
tar -xf /tmp/openjdk.tar.gz; \
jdir=$(dirname $(dirname $(find /opt/java/openjdk -name javac))); \
mv ${jdir}/* /opt/java/openjdk; \
rm -rf ${jdir} /tmp/openjdk.tar.gz;
ENV JAVA_HOME=/opt/java/openjdk \
PATH="/opt/java/openjdk/bin:$PATH"
Note: I dropped some SHA sum checks in favor of making the command shorter.
So I did some research into public PPAs, and I couldn't find one that has a compilation of open-jdk10 for Debian-stretch. There is one for multiple versions of Ubuntu.
If you want maven + python 3 + java 10 installed I think you have a couple of options.
Find an image with maven + java 10 then install python 3 yourself.
Download and install the JDK by hand and setup the correct variables to add it to your PATH. See https://www.rosehosting.com/blog/how-to-install-java-10-on-debian-9/
Use an Ubuntu based image like this (https://github.com/FNNDSC/ubuntu-python3/blob/master/Dockerfile), so that you can use this PPA which has distributions of openjdk for 10.
The full story here is that I want to use AWS Codebuild to compile a Java10 + JavaFX app.
So I made a docker image from the open JDK. Here it is.
But looks like it doesn't include JavaFX.
So I installed that too by adding
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y openjfx
But still I'm getting errors when I try the build
error: module not found: javafx.controls
requires javafx.controls;
if I do java --list-modules javafx doesn't show..
Any pointers would be appreciated!
!!update!!
so i got a dockerfile to work.
FROM ubuntu:14.04.5
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y software-properties-common python-software-properties
RUN add-apt-repository ppa:linuxuprising/java
RUN apt-get update
RUN apt-get install -y libx11-6
RUN echo debconf shared/accepted-oracle-license-v1-1 select true | \
debconf-set-selections
RUN echo debconf shared/accepted-oracle-license-v1-1 seen true | \
debconf-set-selections
RUN apt-get install -y oracle-java10-installer
RUN apt-get update
RUN apt-get upgrade -y
so this has been running now for a while and seems ok... so i guess i can close the Q.
FROM ubuntu:14.04.5
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y software-properties-common python-software-properties
RUN add-apt-repository ppa:linuxuprising/java
RUN apt-get update
RUN apt-get install -y libx11-6
RUN echo debconf shared/accepted-oracle-license-v1-1 select true | \
debconf-set-selections
RUN echo debconf shared/accepted-oracle-license-v1-1 seen true | \
debconf-set-selections
RUN apt-get install -y oracle-java10-installer
RUN apt-get update
RUN apt-get upgrade -y
I'm trying to install java7 via ppa (RUN add-apt-repository ppa:webupd8team/java -y) in my docker image but it fails with this error:
returned a non-zero code: 127
The following are suggested ways to install correctly but it's not working. I've tried both ppas as well.
RUN apt-get install python-software-properties -y
RUN add-apt-repository ppa:webupd8team/java -y
#RUN add-apt-repository ppa:eugenesan/java -y
RUN apt-get update
RUN apt-get install oracle-java7-installer -y
Here is the log output:
Step 28 : RUN add-apt-repository ppa:webupd8team/java -y
---> Running in b278761a4209
[91m/bin/sh: 1: add-apt-repository: not found
[0m
So...I need to find out where/if this command exist in a helper lib or what:
add-apt-repository
add-apt-repository appears to be a part of the python-software-properties install. I don't see any real errors in that step except for these messages which pop up in other areas of the build. So I assume that if I can resolve this issue the aforementioned python step will install as needed:
[91mdebconf: unable to initialize frontend: Dialog
debconf: (TERM is not set, so the dialog frontend is not usable.)
debconf: falling back to frontend: Readline
[0m[91mdebconf: unable to initialize frontend: Readline
debconf: (This frontend requires a controlling tty.)
debconf: falling back to frontend: Teletype
[0m[91mdpkg-preconfigure: unable to re-open stdin:
So. How to set a term or dialog up? I thought the -y allowed this
The -y in your apt-get install commands is telling apt-get to "assume yes", which isn't the same as running in non-interactive mode.
You're seeing the "unable to initialize frontend: Dialog" messages because Debian is running apt-get in interactive mode. To tell it to run in non-interactive mode, add this line to the start of your Dockerfile:
ENV DEBIAN_FRONTEND noninteractive
Now your commands will be running in non-interactive mode, so apt-get won't try and pop any dialogs up.
As for your actual error, you're right, add-apt-repository is a part of the python-software-properties. Try putting your apt-get update -y command above your apt-get install python-software-properties command.
RUN apt-get update -y && \
apt-get install python-software-properties -y && \
add-apt-repository ppa:webupd8team/java -y && \
apt-get update -y && \
apt-get install oracle-java7-installer -y && \
oracle-java7-set-default
Note, you'll need to do two apt-get update -y commands, one before you start (always a good habit to get into) and one after you've added the oracle java PPA.
apt-get manual
Docker ENV docs
add-apt-repository command is a part of software-properties-common pakage. Install software-properties-common, not python-software-properties.
Then you can add ppa:webupd8team repository. But there is still a problem.
Set the accepted-oracle-license-v1-1 and install java. Below sample Dockerfile will work perfectly.
FROM ubuntu:14.04
RUN apt-get update
RUN apt-get install software-properties-common -y
RUN add-apt-repository ppa:webupd8team/java -y
RUN apt-get update
RUN echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections
RUN apt-get install oracle-java7-installer -y
Way #1
Somebody said this way not working but i tested it works.
ENV DEBIAN_FRONTEND noninteractive
yes | apt-get install package-1 package-2
Way #2
ENV DEBIAN_FRONTEND noninteractive
apt-get install -y package-1 package-2