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

Analysis of Alibaba Cloud CentOS7 server nginx configuration and FAQs

Preface: This article refers to jackyzm's blo...

A brief discussion on the lazy loading attribute pattern in JavaScript

Table of contents 1. Introduction 2. On-demand at...

Nginx proxy axios request and precautions

Preface I recently wrote a small demo. Because I ...

jQuery clicks on the love effect

This article shares the specific code of jQuery&#...

JS implementation of carousel carousel case

This article example shares the specific code of ...

Example of how to set up a Linux system to automatically run a script at startup

Preface Hello everyone, I am Liang Xu. At work, w...

Solution to forgetting the password of the pagoda panel in Linux 3.X/4.x/5.x

Enter ssh and enter the following command to rese...

CSS float property diagram float property details

Using the CSS float property correctly can become...

Vue project @change multiple parameters to pass multiple events

First, there is only one change event. changeleve...

Detailed explanation of Excel parsing and exporting based on Vue

Table of contents Preface Basic Introduction Code...

How to use Linux whatis command

01. Command Overview The whatis command searches ...

Vue.$set failure pitfall discovery and solution

I accidentally found that Vue.$set was invalid in...