How to run the springboot project in docker

How to run the springboot project in docker

1. Click Terminal below in IDEA and enter mvn clean install

When the following figure appears, it indicates success (the premise is that Maven must be installed locally and the Maven environment variables must be configured)

The packaged jar is in the target directory

2. Then create a new Dockerfile file with the following content

3. Build the image: Place the Dockerfile and project jar package in the same directory on the server, and then enter the directory

Enter: docker build -t app . (note there is a dot at the end, app is the custom image name) to build the image

Check if the image exists: docker images

4. Run the image just created: docker run -d -p 8888:8081 --name app app

illustrate:

-d runs the container in the background;

--name specifies the container name;

-p specifies the port where the service runs (the first one is the host mapping port number, and the second one is the project port number)

Open the browser IP:8888 to view

5. View container logs: docker logs -f -t --tail 500 app

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed tutorial on running multiple Springboot with Docker
  • Detailed explanation of the infinite restart problem when running the SpringBoot project docker environment
  • Implementation of running springboot project with Docker

<<:  Detailed explanation of mysql transaction management operations

>>:  JavaScript Objects (details)

Recommend

Have you really learned MySQL connection query?

1. Inner Join Query Overview Inner join is a very...

33 of the best free English fonts shared

ChunkFive Free Typefamily Cuprum JAH I Free font Y...

Detailed explanation of js closure and garbage collection mechanism examples

Table of contents Preface text 1. Closure 1.1 Wha...

Detailed explanation of Vue project optimization and packaging

Table of contents Preface 1. Routing lazy loading...

HTML+CSS+JS sample code to imitate the brightness adjustment effect of win10

HTML+CSS+JS imitates win10 brightness adjustment ...

A brief analysis of MySQL backup and recovery

Table of contents 1. Introduction 2. Simple defin...

The whole process record of introducing Vant framework into WeChat applet

Preface Sometimes I feel that the native UI of We...

WeChat Mini Program User Authorization Best Practices Guide

Preface When developing WeChat applets, you often...

Detailed explanation of Linux commands sort, uniq, tr tools

Sort Tool The Linux sort command is used to sort ...

MySQL foreign key (FOREIGN KEY) usage case detailed explanation

Introduction: The disadvantages of storing all da...

Troubleshooting of master-slave delay issues when upgrading MySQL 5.6 to 5.7

Recently, when upgrading the Zabbix database from...