前期准备

已构建centos67-ssh:5.3镜像

Dockerfile内容

FROM centos67-ssh:5.3
COPY jdk-8u181-linux-x64.tar.gz /root/jdk-8u181-linux-x64.tar.gz
RUN tar -zxf /root/jdk-8u181-linux-x64.tar.gz -C /opt \
&& mv /opt/jdk1.8.0_181 /opt/java
ENV JAVA_HOME=/opt/java
ENV PATH=$PATH:$JAVA_HOME/bin
WORKDIR $JAVA_HOME
RUN rm -rf /root/jdk-8u181-linux-x64.tar.gz \
&& rm -rf $JAVA_HOME/src.zip \
&& rm -rf $JAVA_HOME/javafx-src.zip \
&& rm -rf /usr/bin/java \
&& ln -s $JAVA_HOME/bin/java /usr/bin/java \
&& yum clean all \
&& rm -rf /var/cache/yum/* \
&& chkconfig iptables off
EXPOSE 22
CMD service crond start; /usr/sbin/sshd –D

构建命令

进入到Dockerfile文件所在目录,执行以下命令:

sudo docker build -t centos67-ssh53-java:1.8 .

Logo

更多推荐