Build a java web environment with Dockerfile

Building a Java web environment with dockerfile is mainly divided into two steps. The first step is to install jdk in the image and configure environment variables, and the second step is to install tomcat.
First post the complete dockerfile

FROM ubuntu:14.04  
MAINTAINER *** "***@******.com"  

RUN apt-get update  
ADD jdk-8u77-linux-x64.tar.gz /usr/local/java  

ENV JAVA_HOME /usr/local/java/jdk1.8.0_77  
ENV PATH $JAVA_HOME/bin:$PATH  
ENV CLASSPATH .:$JAVA_HOME/lib  
 ENV LANG C.UTF-8
COPY apache-tomcat-8.0.33/ /usr/local/tomcat/apache-tomcat-8.0.33/  
#RUN unzip /usr/local/tomcat/apache-tomcat-8.0.33.zip  
RUN chmod +x /usr/local/tomcat/apache-tomcat-8.0.33/bin/*.sh  
EXPOSE 8080  
ENTRYPOINT /usr/local/tomcat/apache-tomcat-8.0.33/bin/startup.sh && /bin/bash  


The original image is ubuntu14.04, and then put the jdk and tomcat installation packages in the same directory as the dockerfile.
This Dockerfile is relatively simple. JDK and tomcat do not need to be compiled. They are both decompressed and used, so there is nothing special.

After editing the Dockerfile, build the image in the folder where the Dockerfile is located
docker build -t="redstarofsleep/javaweb" .  

Finally run the mirror, remember to bind the port when running the mirror
docker run -d -t -i -p 8081:8080 redstarofsleep/javaweb
 

http://blog.csdn.net/redstarofsleep/article/details/53669003

Guess you like

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