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

Add a startup method to Linux (service/script)

Configuration file that needs to be loaded when t...

How does MySQL ensure master-slave consistency?

Table of contents The basic principle of MySQL ma...

Win10 uses Tsinghua source to quickly install pytorch-GPU version (recommended)

Check whether your cuda is installed Type in the ...

How to delete a MySQL table

It is very easy to delete a table in MySQL, but y...

Avoiding Problems Caused by Closures in JavaScript

About let to avoid problems caused by closure Use...

Solution to EF (Entity Framework) inserting or updating data errors

Error message: Store update, insert, or delete st...

Solution to Ubuntu not being able to connect to the Internet

Problem description: I used a desktop computer an...

How to use geoip to restrict regions in nginx

This blog is a work note environment: nginx versi...

Descending Index in MySQL 8.0

Preface I believe everyone knows that indexes are...

Teach you how to use vscode to build a react-native development environment

question The code has no prompt: Many non-front-e...

How to improve Idea startup speed and solve Tomcat log garbled characters

Table of contents Preface Idea startup speed Tomc...

Detailed installation process of MySQL5.6.40 under CentOS7 64

MySQL5.6.40 installation process under CentOS7 64...

How does Vue3's dynamic components work?

Table of contents 1. Component Registration 1.1 G...

How to manually build a new image with docker

This article introduces the method of manually bu...