Method of deploying spring boot Maven application using docker
This article introduces the deployment of spring boot Maven application using docker and shares it with you as follows:
The deployment process is divided into the following steps:
1. Create a simple spring boot application
Then click Next - > finish
2. Package and run the application
pom. Add dependency to XML:
Add a controller:
Run the project to access: http://localhost:8080/hello , if it appears: Hello spring boot, step 2 is completed
3. Container application
Create a dockerfile in the project directory: Src / main / docker / dockerfile (no suffix), as follows:
Where demo-0.0 1-SNAPSHOT. Jar is the file name in / target / after the project is packaged
4. Add docker support in POM file
5. Create docker image
CMD enters the current directory:
Package, create image:
Note: please ensure that Maven has been added to the path; And docker has been installed. If not, please visit: https://www.docker.com/community-edition#/download Download the appropriate version