How to install tomcat8 in docker

How to install tomcat8 in docker

1. Install tomcat8 with docker

1. Find the tomcat image on Docker Hub

docker search tomcat

2. Pull the tomcat image

docker pull tomcat:8

3. Use the default configuration of Tomcat to start a Tomcat container

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

4. Copy the tomcat configuration files and logs in the container to the local machine for mapping

docker cp tomcat:/usr/local/tomcat/conf /usr/app/tomcat/conf
docker cp tomcat:/usr/local/tomcat/logs /usr/app/tomcat/logs

5. Stop tomcat and delete the container

docker stop tomcat
docker rm tomcat

6. Create and run the tomcat container

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:8

7. View the created container

docker ps | grep tomcat

Notice

When the Tomcat version is too high, the following problems may occur when accessing based on the IP address and port number:

The 404 error occurs because the content in the webapps folder is empty. The content is in the webapps.dist directory. The solution is as follows:

1. Enter the tomcat container

docker exec -it container id /bin/bash

2. Use ls to view the folder contents. You can find that there are webapps folder and webapps.dist folder. Move all the contents under webapps.dist to webapps.

mv webapps.dist/* webapps

3. Revisit tomcat.

Remember to allow security groups and firewalls.

This is the end of this article about how to install tomcat8 with docker. For more information about installing tomcat8 with docker, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • 404 error occurs when accessing the homepage of tomcat started in Docker mode
  • How to install tomcat in docker and deploy the Springboot project war package
  • Steps to deploy multiple tomcat services using DockerFile on Docker container
  • Docker Nginx container and Tomcat container to achieve load balancing and dynamic and static separation operations
  • Detailed steps for installing Tomcat, MySQL and Redis with Docker
  • Why can't I see the access interface for Docker Tomcat?
  • How to set the memory size of Docker tomcat

<<:  HTML Tutorial: title attribute and alt attribute

>>:  How to use cursor triggers in MySQL

Recommend

Solution to CSS anchor positioning being blocked by the top fixed navigation bar

Many websites have a navigation bar fixed at the ...

A magical MySQL deadlock troubleshooting record

background Speaking of MySQL deadlock, I have wri...

Detailed steps for creating a Vue scaffolding project

vue scaffolding -> vue.cli Quickly create a la...

VUE implements token login verification

This article example shares the specific code of ...

Tutorial on using $attrs and $listeners in Vue

Table of contents introduce Example Summarize int...

Detailed explanation of styles in uni-app

Table of contents Styles in uni-app Summarize Sty...

Analysis of rel attribute in HTML

.y { background: url(//img.jbzj.com/images/o_y.pn...

A brief analysis of Vue's asynchronous update of DOM

Table of contents The principle of Vue asynchrono...

Examples of using && and || operators in javascript

Table of contents Preface && Operator || ...

Example of how to implement embedded table with vue+elementUI

During my internship in my senior year, I encount...

Detailed explanation of Mysql communication protocol

1.Mysql connection method To understand the MySQL...

How to use the realip module in Nginx basic learning

Preface There are two types of nginx modules, off...