Docker install tomcat tutorial
Docker installation tutorial: original
Docker install tomcat image
Pull tomcat image
docker search tomcat
Pull the latest tomcat
docker pull tomcat:latest
View the pulled tomcat
docker images
Create tomcat container
Create tomcat container
docker run -d -p 8080:8080 --name tomcat tomcat:latest
Copy the tomcat configuration file to delete the original image
mkdir -p /usr/app/tomcat
docker cp tomcat:/usr/local/tomcat/conf /usr/app/tomcat/conf
docker cp tomcat:/usr/local/tomcat/logs /usr/app/tomcat/logs
docker stop tomcat
docker rm tomcat
Recreate the image and add the configuration file
docker run -d -p 8080:8080 --name tomcat -v /usr/app/tomcat/webapps:/usr/local/tomcat/webapps -v /usr/app/tomcat/conf:/usr/local/tomcat/conf -v /usr/app/tomcat/logs:/usr/local/tomcat/logs --restart=always tomcat:latest
View the created tomcat container
docker ps | grep tomcat
View the ip address of the container
docker inspect --format='{
{.NetworkSettings.IPAddress}}' tomcat
Check whether tomcat is installed
Installation failure and solutions
If it shows that this website cannot be accessed , if it does not show, check whether the firewall
opens port 8080 or close the firewall. Open the tomcat webapps directory
cd /usr/app/tomcat/webapps/
ls
![Insert picture description here]
If there is no ROOT directory, the
ROOT directory extraction code: kg76
upload the ROOT file and
decompress the ROOT file
tar -zxvf ROOT.tar.gz
Restart tomcat
docker start tomcat
Successful installation
Then you can see this, indicating that the tomcat installation is successful
View log
Enter this command to see this tomcat log
docker logs -f -t --tail 20 tomcat
The installation is complete!
The war package of the project written in the future can be placed in this directory and the project can be deployed by restarting tomcat.