2

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 ?

2
  • The title of your question is misleading, you should change it. Especially because someone might assume that you are asking for off-site content. Commented Jun 20, 2019 at 14:48
  • It's typically easier to start with a Java (or maven) container, then install Python Commented Jun 21, 2019 at 12:32

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

  1. Find an image with maven + java 10 then install python 3 yourself.
  2. 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/
  3. 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.

7 Comments

add-apt-repository ppa:linuxuprising/java will fail you need to add apt-get install software-properties-common -y, and even than it will not work
@EhudLev Yeah you're right those are definitely manual steps. Need the -y to force auto-accept. What problem are you running into during the installation, though?
I am trying to install it inside the docker while it is running. I mean "docker run -it python:3.6.6-stretch bash" is it makes a different ?
@EhudLev Running a user inside the docker to install these packages (or test installing them) should be fine. Make sure you have sudo privilege as that user (if you're not root) so you can sudo before the apt-get installs. I'm going to pull down a copy real quick and see what kind of errors I get. Have to run for lunch soon but I can look at it again after I get back.
@EhudLev Woops it looks like that PPA removed the Java 10 download. Do you NEED Java 10 specifically? Can you use Java 11?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.