Docker基于centos7搭建Java环境

# Pull base image
FROM hub.c.163.com/netease_comb/centos:7

MAINTAINER Alenx "[email protected]"

# update source
RUN yum makecache && yum -y update glibc

# Install curl
RUN yum install -y curl
RUN yum install -y openssh-server vim tar wget curl rsync bzip2 iptables tcpdump less telnet net-tools lsof

# add admin
RUN groupadd -r admin && useradd -r -d /opt/admin -g admin -m admin

# add log
RUN mkdir /opt/log
RUN chown admin.admin -R /opt/log
RUN chmod 777 -R /opt/log

# Install JDK 7
RUN cd /usr/local/ &&  curl -L 'http://download.oracle.com/otn-pub/java/jdk/7u65-b17/jdk-7u65-linux-x64.tar.gz' -H 'Cookie: oraclelicense=accept-securebackup-cookie; gpw_e24=Dockerfile' | tar -xz
RUN mv /usr/local/jdk1.7.0_65 /usr/local/java1.7

# Set Oracle JDK 7 as default Java
RUN alternatives --install /usr/bin/java java /opt/jdk1.7/bin/java 1
RUN alternatives --install /usr/bin/javac javac /opt/jdk1.7/bin/javac 300

ENV JAVA_HOME /usr/local/java1.7

# start user
USER admin

# workdir
WORKDIR /opt/admin

# add dir
RUN mkdir -v application config tpc script

# Install tomcat7
RUN cd /opt/admin/tpc/ && curl -L 'http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.8/bin/apache-tomcat-7.0.8.tar.gz' | tar -xz
RUN mv /opt/admin/tpc/apache-tomcat-7.0.8 /opt/admin/tpc/tomcat7

ENV CATALINA_HOME /opt/admin/tpc/tomcat7
ENV PATH $PATH:$CATALINA_HOME/bin

# Expose ports.
EXPOSE 22 8080


# copy tomcat.sh
COPY tomcat7.sh /opt/admin/script/

# Define default command.
ENTRYPOINT bash /opt/admin/script/tomcat7.sh start && tail -f /opt/admin/tpc/tomcat7/logs/catalina.out

你可能感兴趣的:(Linux,Docker,Linux)