Docker install tomcat tutorial

Docker install tomcat tutorial

  Docker installation tutorial: original

Docker install tomcat image

Pull tomcat image

docker search tomcat

Insert picture description here
Pull the latest tomcat

docker pull tomcat:latest

Insert picture description here
View the pulled tomcat

docker images

Insert picture description here

Create tomcat container

Create tomcat container

docker run -d -p 8080:8080 --name tomcat tomcat:latest

Insert picture description here
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

Insert picture description here
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

Insert picture description here
View the created tomcat container

docker ps | grep tomcat

Insert picture description here
View the ip address of the container

docker inspect --format='{
    
    {.NetworkSettings.IPAddress}}' tomcat

Insert picture description here

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
Insert picture description here
opens port 8080 or close the firewall. Open the tomcat webapps directory

cd /usr/app/tomcat/webapps/
ls

![Insert picture description here] (https://img-blog.csdnimg.cn/20210226163801585.png)
If there is no ROOT directory, the
  ROOT directory   extraction code: kg76
upload the ROOT file and
Insert picture description here
decompress the ROOT file

tar -zxvf ROOT.tar.gz 

Insert picture description here
Restart tomcat

docker start tomcat

Insert picture description here

Successful installation

Then you can see this, indicating that the tomcat installation is successful
Insert picture description here

View log

Enter this command to see this tomcat log

docker logs -f -t --tail 20 tomcat

Insert picture description here
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.

Original by weixin_45351743

Guess you like

Origin blog.csdn.net/weixin_45351743/article/details/114131370