17. Docker uses dockerfile to create jdk image

Anyone who is familiar with java knows how to configure the java development environment. We build a new image based on the nginx:v1.0 in the previous section as the base image:

First, look at the local mirror:

Description: This dockerfile mainly reflects the usage of ENV environment configuration;

Second, start writing the dockerfile:

FROM nginx:v1.0

#MAINTAINER,this dockerfile creater
MAINTAINER [email protected]

#Create /usr/local/ jdk directory for wget installation package directory
RUN mkdir /usr/local/jdk

#Upload the jdk.tar.gz package to the /usr/local/ jdk directory
ADD jdk -7u80-linux-x64.tar.gz /usr/local/ jdk
 #wget jdk to the specified directory (jdk download needs to agree to the license, the currently downloaded package cannot be decompressed, so jdk does not use wget method, directly tar.gz package upload) #RUN wget -P /usr/local/jdk http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz #Even 
if the command contains click to agree license, the downloaded tar.gz package cannot be decompressed
.#wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn -pub/java/jdk/8u111-b14/jdk-7u79-linux-x64.tar.gz
#Configure environment variables ENV JAVA_HOME /usr/local/jdk/jdk1.7.0_80 ENV PATH $PATH:$JAVA_HOME/bin

Finally, start building:

Check out the local mirror:

Start the container from the image and check the jdk version:

Finally, visit the webpage again to see if nginx is normal:

In this way, our image not only has nginx, but also integrates JDK!

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325038089&siteId=291194637