1. First pull the image docker search tomcat
2. After pulling, check the mirror docker images
3. Start a tomcat t1
docker run -id --name=t1 -p 8080:8080 tomcat
4. After tapping the address, you will find that the page displays 404
5. What is the reason? Go inside to see what is going on
docker exec -it 75 /bin/bash
You will find that there is an extra webapps.dist folder when you enter it, and you will find that the webapps is empty and webapps.dist should be the contents of webapps.
As for the above, the blogger did not figure out the reason. Haha.
6. Now we start to deploy the project using data storage volumes
Use root to enter /usr/local/ and create a folder docker/tomcat/
Now we need to copy the webapps.dist of t1 to /tomcat/webapps of the host
docker cp t1:/usr/local/tomcat/webapps.dist webapps
7. New tomcat for t2 and t3
docker run -id --name=t2 -p 8881:8080 -v $PWD:/usr/local/tomcat/webapps tomcat
docker run -id --name=t3 -p 8882:8080 -v $PWD:/usr/local/tomcat/webapps tomcat
8. Now create a new page test/index.html in the local storage volume
9. View the effect. At this time, both tomcats are using the items in the shared storage volume
10. Use nginx to build a load balancer. No more demonstrations here.