1.Dockerfile-tomcat镜像构建
FROM centos:latest
MAINTAINER NAN
ENV VERSION=8.5.42
RUN yum install java-1.8.0-openjdk wget curl unzip iproute net-tools -y &&\
yum clean all && \
rm -rf /var/cache/yum/*COPY apache-tomcat-8.5.42.tar.gz /tmp
RUN cd /tmp && \
tar zxf apache-tomcat-${VERSION}.tar.gz && \
mv apache-tomcat-${VERSION} /usr/local/tomcat && \
rm -rf apache-tomcat-${VERSION}.tar.gz /usr/local/tomcat/webapps/* && \
sed -i ‘1a JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom"‘ /usr/local/tomcat/bin/catalina.sh && \
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtimeENV PATH $PATH:/usr/local/tomcat/bin/
WORKDIR /usr/local/tomcat
EXPOSE 8080
CMD ["catalina.sh","run"]
tomcat链接下载可自行去官网下载,构建完成的镜像可提交至本地harbor仓库中.
2.下载镜像并构建业务镜像
2.1 docker pull xx.xx.xx.xx/library/tomcat:v1 #从镜像仓库拉取自己构建的tomcat镜像.
2.2 业务镜像:
mkdir -p /opt/tomcat/
ROOT.war 放在/opt/tomcat目录下.
Dockerfile业务镜像构建文件:
FROM 188.131.244.172/library/tomcat:v1
MAINTAINER NAN
COPY ROOT.war /usr/local/tomcat/webapps/cd /opt/tomcat/
docker build -t mall:new -f Dockerfile .
3.启动容器
docker run -d --name mall -p 8090:8080 mall:new
原文地址:https://blog.51cto.com/12191723/2418430