Use Docker to install the latest version of Tomcat image and explain the 404 phenomenon

  1. There is a command docker pull tomcat to pull the latest tomcat image
  2. Use docker images command, whether the pull is successful
    Insert picture description here
  3. Use the command docker run --name mytomcat -p 8080:8080 -d tomcat to create the container
    Use the command docker ps to see if the creation is successful --name
    : give the created container a name
    -p: correspond the port number of the host to the port number of the container
    -d: Mirror name
    Insert picture description here
    Description of the problem
    After installing docker, directly pull the tomcat image of Alibaba Cloud. There is no problem when it starts successfully, but this will happen when accessing the address. The
    Insert picture description here
    cause of the problem is that
    the tomcat image pulled directly contains a webapps and a webapps The .dist folder, our normal access situation is the webapps folder, but the image we pulled directly is empty and there is nothing, so the access result is 404

Solution
Copy the content of webapps.dist to webapps and it's ok.
Use docker exec-it mytomcat /bin/ bash to enter tomcat
-i: interactive
-t: terminal
Insert picture description here
Then copy the content of webapps.dist to webapps
Insert picture description here
and then access it.
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_2662385590/article/details/106583544