How to install tomcat in docker and deploy the Springboot project war package

How to install tomcat in docker and deploy the Springboot project war package

It's simple, just go to the tutorial, blogger

1. First start docker

service docker start

2. Pull the tomcat image.

docker pull tomcat:8-jdk8

If you don't add the 8-jdk8 tag, the latest version will be pulled by default, which is the latest official version.

3. After the installation is complete, create a container and start tomcat

docker run --name tomcat -p 8080:8080

If a 404 error occurs when accessing the IP+port after normal installation, enter the tomcat directory, delete the original webapps directory, and rename webapps.dist to webapps. The command is as follows

rm -rf webapps

mv webapps.dist webapps

4. Check the container operation status

docker ps

5. Then package the springboot project, taking the war package as an example

<dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
      <exclusions>
        <exclusion>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

First exclude the tomcat that comes with springboot

<plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>

Then add the Maven packaging component

6. Package in IDEA, then check the target folder of the project, find the corresponding war package, and copy it to the corresponding directory in Linux

7. Copy the war package into the webapps directory of the tomcat container and check whether it is copied correctly

docker cp consumer-0.0.1-SNAPSHOT.war 7d64a9eaa278:/usr/local/tomcat/webapps

docker exec -it 7d64a9eaa278 /bin/bash

8. Restart tomcat and access ip+port+project name again

docker restart 7d64a9eaa278

Done!

This is the end of this article about how to install tomcat with docker and deploy the Springboot project war package. For more information about how to install tomcat with docker and deploy the Springboot project war package, 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:
  • Tomcat reports an error when starting the springboot project war package: Error when starting the child
  • How to run SpringBoot as a war package under tomcat or wildfly
  • How to package eclipse springboot project into war package and run it in Tomcat
  • How to deploy SpringBoot application War package to external Tomcat
  • SpringBoot war package deployed to Tomcat server
  • How to deploy Springboot into a war package and run it in tomcat
  • Some problems encountered when deploying the springboot project into a war package and deploying it to tomcat
  • Use tomcat to deploy SpringBoot war package in centos environment

<<:  About the problem of dynamic splicing src image address of img in Vue

>>:  XHTML tags have a closing tag

Recommend

Beginners learn some HTML tags (2)

Beginners can learn HTML by understanding some HT...

JavaScript implements displaying a drop-down box when the mouse passes over it

This article shares the specific code of JavaScri...

Optimized implementation of count() for large MySQL tables

The following is my judgment based on the data st...

About MariaDB database in Linux

Table of contents About MariaDB database in Linux...

VMware ESXI server virtualization cluster

Table of contents summary Environment and tool pr...

The most complete package.json analysis

Table of contents 1. Overview 2. Name field 3. Ve...

The best way to start a jar package project under Centos7 server

Preface Everyone knows how to run a jar package o...

CSS Sticky Footer Implementation Code

This article introduces the CSS Sticky Footer imp...

Tutorial on installing AutoFs mount service under Linux

Whether it is Samba service or NFS service, the m...

A complete guide to some uncommon but useful CSS attribute operations

1. Custom text selection ::selection { background...

Java uses Apache.POI to export HSSFWorkbook to Excel

Use HSSFWorkbook in Apache.POI to export to Excel...

Telnet is moved to busybox-extras in Alpine image

The telnet in the Alpine image has been moved to ...