Home >Java >javaTutorial >How to package SpringBoot project into Docker image
Full automation: First build the docker image warehouse, and then configure the warehouse address in the project's maven configuration. Configure the Dockerfile file in the project, so that it can be packaged directly in the idea and automatically uploaded to the image warehouse, and then just start the image on the server.
Semi-automation: There are two options for semi-automation. One is to place the Dockerfile file inside the project, and the other is to place it outside the project.
Put it in the project: configure maven plug-in support in springboot pom.
Generally speaking, semi-automation is used more than full automation. This article uses the second method of semi-automation. Generally speaking, there are several steps:1. Build the SpringBoot project
#发布到网上时只会把jar包和Dockerfile发布上去 COPY *.jar /app.jar #地址映射 CMD ["--server.port=8080"] #对外暴露端口 EXPOSE 8080 #执行命令 ENTRYPOINT ["java","-jar","/app.jar"]4. Build the imageTake out the jar package and Dockerfile file and create a new folder in it, press Hold down the shift key to open PowerShell
(Note: Docker Desktop is installed on my computer)
The above is the detailed content of How to package SpringBoot project into Docker image. For more information, please follow other related articles on the PHP Chinese website!