Solution to the problem of not being able to access the home page when adding a tomcat container to Docker

Solution to the problem of not being able to access the home page when adding a tomcat container to Docker

question

The tomcat container was successfully added using the docker run command. The port was also opened. I also tried to turn off the firewall, but it always displayed 404 when accessing the tomcat homepage.

reason

The default version of the tomcat image obtained using Alibaba Cloud is 8.5.51. Its webapps file is empty, and its welcome page is placed in the webapps.dist file. This is why we will access it incorrectly.

Workaround

Delete the original webapps or change its name to another one, and rename webapps.dist to webapps

The steps are as follows:

1. Enter the interactive mode with tomcat in docker

[root@localhost ~]# docker exec -it your tomcat container ID /bin/bash

root@b3589cdf16cc:/usr/local/tomcat#

2. Modify the directory

ls -lroot@b3589cdf16cc:/usr/local/tomcat# mv webapps webapps2

root@b3589cdf16cc:/usr/local/tomcat# mv webapps.dist

3. Exit interactive mode

webappsroot@b3589cdf16cc:/usr/local/tomcat# exit

Example:

Access port 32768 in the host machine, which will be mapped to port 8080 of tomcat

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Why can't I see the access interface for Docker Tomcat?

<<:  React realizes the whole process of page watermark effect

>>:  Essential bonus items for optimizing and packaging the front end of Vue projects

Recommend

Implementation example of JS native double-column shuttle selection box

Table of contents When to use Structural branches...

Index Skip Scan in MySQL 8.0

Preface MySQL 8.0.13 began to support index skip ...

MySQL trigger trigger add, delete, modify and query operation example

This article uses examples to describe the add, d...

Solution to "No input file specified" in nginx+php

Today, the error "No input file specified&qu...

How to deploy a simple c/c++ program using docker

1. First, create a hello-world.cpp file The progr...

Some CSS questions you may be asked during an interview

This article is just to commemorate those CSS que...

Complete Tutorial on Deploying Java Web Project on Linux Server

Most of this article refers to other tutorials on...

Summary of how to use the MySQL authorization command grant

How to use the MySQL authorization command grant:...

Example of using store in vue3 to record scroll position

Table of contents Overall Effect Listen for conta...

Vue implements drag progress bar

This article example shares the specific code of ...

How to implement controllable dotted line with CSS

Preface Using css to generate dotted lines is a p...

How to reset MySQL root password

Table of contents 1. Forgot the root password and...