简体   繁体   中英

How to run java10 inside Docker of python3.7?

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.

  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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM