Categories: DevOpsDockers

Docker – How to Build & Get Started with Java 7 Container

This article represents tips and code samples on how to build a Java7 docker image and start Java 7containers. Please feel free to comment/suggest if I missed to mention one or more important points. Also, sorry for the typos.

Following are the key points described later in this article:

  • Dockerfile to Build Java 7 Image
  • Command to Start Java 7 Container

 

Dockerfile to Build Java 7 Image

Following is the code for Dockerfile which could be used to build Java 7 image:

FROM centos:centos6

RUN mkdir /opt/jdk
RUN cd /opt

RUN yum -y install wget tar

RUN wget --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz

RUN tar -zxf jdk-7u79-linux-x64.tar.gz -C /opt/jdk

RUN update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.7.0_79/bin/java 100
RUN update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.7.0_79/bin/javac 100

Save the above file as java7.df. In the same folder, execute the following command. It would build the image with name as “java7”.

docker build -t java7 -f java7.df .

Note that “java7” is name of the image and “java7.df” is the dockerfile.

 

Command to Start Java 7 Container

Once the image is built, you could start as many containers with following command:

# Start the container, namely, java7_container, using the image java7
docker run --privileged=true -ti -dP --name java7_container -v /c/Users:/mnt/Users java7 /bin/bash

# Access the container
docker exec -ti java7_container /bin/bash

 

Ajitesh Kumar

I have been recently working in the area of Data analytics including Data Science and Machine Learning / Deep Learning. I am also passionate about different technologies including programming languages such as Java/JEE, Javascript, Python, R, Julia, etc, and technologies such as Blockchain, mobile computing, cloud-native technologies, application security, cloud computing platforms, big data, etc. I would love to connect with you on Linkedin. Check out my latest book titled as First Principles Thinking: Building winning products using first principles thinking.

Share
Published by
Ajitesh Kumar
Tags: docker

Recent Posts

ROC Curve & AUC Explained with Python Examples

Last updated: 28th Aug, 2024 Confusion among data scientists regarding ROC Curve and AUC often…

2 weeks ago

Accuracy, Precision, Recall & F1-Score – Python Examples

Last updated: 27th Aug, 2024 Classification models are used in classification problems to predict the…

2 weeks ago

Logistic Regression in Machine Learning: Python Example

Last updated: 26th August, 2024 In this blog post, we will discuss the concepts of…

2 weeks ago

Reducing Overfitting vs Models Complexity: Machine Learning

Last updated: 25th August, 2024 In machine learning, model complexity and overfitting are related in…

2 weeks ago

Model Parallelism vs Data Parallelism: Examples

Last updated: 24th August, 2024 Model parallelism and data parallelism are two strategies used to…

2 weeks ago

Overfitting & Underfitting in Machine Learning

Last updated: 24th August, 2024 The performance of the machine learning models on unseen datasets…

2 weeks ago