Environmental information:
MacBook Pro(M1)
VMware-fusion(Player version 13.0.0 (20802013))
Ubuntu 22.10
tomcat mirror:
centos-7.9.2009
jdk1.8.0_341
apache-tomcat-8.5.84
Production steps:
(1) Download tomcat/jdk (I made it on macbook pro, so I used aarch64 SDK)
Note that apache-tomcat-8.5.84, jdk1.8.0_341 and Dockerfile must be placed in the same directory
(2) Dockerfile file content
FROM centos:7.9.2009
#install jdk/tomcat
ADD jdk1.8.0_341 /usr/local/jdk
ADD apache-tomcat-8.5.84 /usr/local/tomcat
ENV WORKDIR /usr/local
WORKDIR $WORKDIR
ENV JAVA_HOME /usr/local/jdk
ENV CATALINA_HOME /usr/local/tomcat
ENV PATH $PATH:$JAVA_HOME/bin:$CATALINA_HOME/bin
EXPOSE 8080
CMD ["/usr/local/tomcat/bin/catalina.sh","run"]
(3) Build the image:
docker build -t centos-7.9.2009-tomcat-8.5.84:5.0 .
(4) Start the image:
docker run -d -p 8080:8080 --name tomcatv5 centos-7.9.2009-tomcat-8.5.84:5.0
(5) Check the startup log:
docker logs 187b4a6de782143edc69e93ea54235233fbdac6d25dafc0fefafed8c266bfc8f
(6) View the container:
docker ps -a
(7) Enter command mode:
docker exec -it 187b4a6de782143edc69e93ea54235233fbdac6d25dafc0fefafed8c266bfc8f /bin/bash
(8) Execute the following command on the host machine to access the tomcat service provided by docker
http://172.16.218.128:8080/ , where the IP address of 172 is the IP of the host machine
Once encountered docker (56) Recv failure: Connection reset by peer, restart the docker service and it will be OK.