Following are the key points described later in this article:
Following is dockerfile to build Java 7 image. Save the file as java7.df for the code example (shell script startJava.sh) to work.
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
Following is dockerfile to build Java8 image. Save the file as java8.df for the code example (shell script startJava.sh) to work.
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/8u5-b13/jdk-8u5-linux-x64.tar.gz RUN tar -zxf jdk-8u5-linux-x64.tar.gz -C /opt/jdk RUN update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_05/bin/java 100 RUN update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_05/bin/javac 100
Save the following script as startJava.sh. Save the above two dockerfiles as java7.df and java8.df in the same folder as the script below. Execute the command such as “./startJava.sh -v 7 java7” to start a Java 7 container with name as “java7” and, “./startJava.sh -v 8 java8” to start the Java 8 Container with name as “java8”. You could then access your source code on your m/c as the volume is mounted appropriately in the script below (/c/Users:/mnt/Users).
#!/bin/sh
if [ $# == 0 ]; then
echo "This script expecs version and container name as argument. Example: ./startJava.sh -v 7 java"
exit 100
fi
if [ $1 == '-v' ]; then
expr $2 + 1 2> /dev/null
if [ $? = 0 ]; then
echo "Version: $2"
else
echo "Version can only be numeric. Value supported are 7, 8"
exit 100
fi
else
echo "This script expecs version and container name as argument. Example: ./startJava.sh -v 7 java"
exit 100
fi
docker stop $3;docker rm $3
java_image=""
java_df=""
if [ $2 == 8 ]; then
java_image="java8_base"#!/bin/sh
if [ $# == 0 ]; then
echo "This script expecs version and container name as argument. Example: ./startJava.sh -v 7 java"
exit 100
fi
if [ $1 == '-v' ]; then
expr $2 + 1 2> /dev/null
if [ $? = 0 ]; then
echo "Version: $2"
else
echo "Version can only be numeric. Value supported are 7, 8"
exit 100
fi
else
echo "This script expecs version and container name as argument. Example: ./startJava.sh -v 7 java"
exit 100
fi
docker stop $3;docker rm $3
java_image=""
java_df=""
if [ $2 == 8 ]; then
java_image="java8_base"
java_df="java8.df"
else
if [ $2 == 7 ]; then
java_image="java7_base"
java_df="java7.df"
else
echo "This script only supports Java containers for version 7 or 8. Please try again!"
exit 100
fi
fi
# Build Java image if it does not exists
#
if [ `docker images $java_image | wc -l` -lt 2 ]; then
echo "Docker Image $java_image do not exist..."
echo "Builing docker image $java_image"
if [ -f $java_df ]; then
docker build -t $java_image -f $java_df .
else
echo "Can't find Dockerfile $java_df in the current location"
exit 200
fi
fi
docker run --privileged=true -ti -dP --name $3 -v /c/Users:/mnt/Users $java_image /bin/bash
docker exec -ti $3 /bin/bash
java_df="java8.df"
else
if [ $2 == 7 ]; then
java_image="java7_base"
java_df="java7.df"
else
echo "This script only supports Java containers for version 7 or 8. Please try again!"
exit 100
fi
fi
# Build Java image if it does not exists
#
if [ `docker images $java_image | wc -l` -lt 2 ]; then
echo "Docker Image $java_image do not exist..."
echo "Builing docker image $java_image"
if [ -f $java_df ]; then
docker build -t $java_image -f $java_df .
else
echo "Can't find Dockerfile $java_df in the current location"
exit 200
fi
fi
docker run --privileged=true -ti -dP --name $3 -v /c/Users:/mnt/Users $java_image /bin/bash
docker exec -ti $3 /bin/bash
If you're starting with large language models, you must have heard of RAG (Retrieval-Augmented Generation).…
If you've spent any time with Python, you've likely heard the term "Pythonic." It refers…
Large language models (LLMs) have fundamentally transformed our digital landscape, powering everything from chatbots and…
As Large Language Models (LLMs) evolve into autonomous agents, understanding agentic workflow design patterns has…
In today's data-driven business landscape, organizations are constantly seeking ways to harness the power of…
In this blog, you would get to know the essential mathematical topics you need to…