镜像加速地址
https://docker.aityp.com/manage/add
下载jdk
https://repo.huaweicloud.com/java/jdk/8u172-b11/
下载镜像
docker pull swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/centos:7.4.1708
jdk的Dockerfile文件
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/centos:7.4.1708
LABEL maintainer="huang.jinjin"
ADD jdk-8u172-linux-x64.tar.gz /usr/local/
ENV JAVA_HOME="/usr/local/jdk1.8.0_172"
ENV JAVA_HOME="/usr/local/jdk1.8.0_172/jre"
ENV CLASSPATH="$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar"
ENV PATH="$JAVA_HOME/bin:$PATH"
构建镜像
docker build -t jdk-1.8.0_172:v1 .
运行jdk镜像
docker images | grep jdk
docker run -it jdk-1.8.0_172:v1 /bin/sh
下载tomcat
wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.95/bin/apache-tomcat-9.0.95.tar.gz
tomcat的Dockerfile
FROM jdk-1.8.0_172:v1
LABEL maintainer="huangjinjin"
ENV WORKDIR="/usr/local"
ADD apache-tomcat-9.0.95.tar.gz $WORKDIR
RUN mv $WORKDIR/apache-tomcat-9.0.95 $WORKDIR/tomcat9 && chmod +x $WORKDIR/tomcat9/bin/*.sh
ENV CATALINA_HOME="$WORKDIR/tomcat9"
ENV PATH="$CATALINA_HOME/bin:$PATH"
EXPOSE 8080
CMD ["$WORKDIR/tomcat9/bin/catalina.sh", "run"]
构建镜像
docker build -t tomcat9.0.95:v1 .
运行镜像
docker run -d -p 8080:8080 --name tomcat9_test tomcat9.0.95:v1