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

HTML 5.1 learning: 14 new features and application examples

Preface As we all know, HTML5 belongs to the Worl...

Detailed description of the function of new in JS

Table of contents 1. Example 2. Create 100 soldie...

Pure CSS to achieve the water drop animation button in Material Design

Preface You should often see this kind of special...

Detailed explanation of Vue two-way binding

Table of contents 1. Two-way binding 2. Will the ...

Ubuntu starts the SSH service remote login operation

ssh-secure shell, provides secure remote login. W...

A simple example of using Vue3 routing VueRouter4

routing vue-router4 keeps most of the API unchang...

CSS3 category menu effect

The CSS3 category menu effects are as follows: HT...

MySQL exposes Riddle vulnerability that can cause username and password leakage

The Riddle vulnerability targeting MySQL versions...

How to redraw Button as a circle in XAML

When using XAML layout, sometimes in order to make...

html option disable select select disable option example

Copy code The code is as follows: <select> ...

How to use Linux paste command

01. Command Overview The paste command will merge...

Detailed explanation of two ways to dynamically change CSS styles in react

The first method: dynamically add a class to show...

Installation method of MySQL 5.7.18 decompressed version under Win7x64

Related reading: Solve the problem that the servi...

Multiple ways to change the SELECT options in an HTML drop-down box

After the form is submitted, the returned HTML pag...