[root@node2 ~]# vim Dockerfile
FROM alpine:3.13.6
RUN set -x; echo "http://mirrors.aliyun.com/alpine/latest-stable/main/" > /etc/apk/repositories && echo "http://mirrors.aliyun.com/alpine/latest-stable/community/" >> /etc/apk/repositories && apk upgrade && apk add --no-cache ca-certificates && apk add --no-cache unzip curl bash bash-doc bash-completion bash wget vim net-tools && rm -rf /tmp/* /var/cache/apk/*
RUN /bin/bash
# set glibc
RUN wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.32-r0/glibc-2.32-r0.apk https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.32-r0/glibc-bin-2.32-r0.apk https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.32-r0/glibc-i18n-2.32-r0.apk https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.32-r0/glibc-dev-2.32-r0.apk
RUN wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub
RUN apk add glibc-2.32-r0.apk glibc-bin-2.32-r0.apk glibc-dev-2.32-r0.apk glibc-i18n-2.32-r0.apk && rm -rf *.apk
ADD jdk-8u301-linux-x64.tar.gz apache-tomcat-9.0.53.tar.gz /
RUN mv /apache-tomcat-9.0.53 /tomcat9 && rm -rf /tomcat9/webapps/{docs,examples,host-manager,manager}
# install JRE
RUN apk add --no-cache openjdk8-jre-base && rm -rf /var/cache/apk/*
COPY Shanghai /etc/localtime
ENV JAVA_HOME=/jdk1.8.0_301
ENV CLASSPATH=JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
ENV PATH=$PATH:.JAVA_HOME/bin:$PATH
EXPOSE 8080
CMD ["/tomcat9/bin/catalina.sh","run"]
[root@node2 ~]# docker build -t alpine:v1 .
该步可自定义添加其他参数
[root@node2 ~]# docker run -itd --name tomcat1 -p 8080:8080 alpine:v1
原文:https://www.cnblogs.com/smlile-you-me/p/15347413.html