Low Orbit Flux Logo 2 F

Docker How To Install Java

Installing Java in a docker container is easy. You just need to copy in the JDK and install it as you normally would. This can be done in a dockerfile. You could also, alternatively, use your systems package manager.

This is a trimmed down example of a docker file that would install Java in a container:

vi Dockerfile
FROM standard #COPY jdk-13.0.1_linux-x64_bin.tar.gz / #RUN tar xvfz jdk-13.0.1_linux-x64_bin.tar.gz #RUN rm jdk-13.0.1_linux-x64_bin.tar.gz #RUN cp -r jdk-13.0.1 /opt #RUN cd /opt && ln -s jdk-13.0.1 java COPY jdk-7u15-linux-x64.tar.gz / RUN tar xvfz jdk-7u15-linux-x64.tar.gz RUN rm jdk-7u15-linux-x64.tar.gz RUN cp -r jdk1.7.0_15 /opt RUN cd /opt && ln -s jdk1.7.0_15 java CMD ["/usr/bin/supervisord"]

Build an image:



docker build -t mytestimage

This is based on my “standard” image. See the example in this lab case study for more details:

*Docker - Hadoop Cluster Lab