Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How Docker deploys springboot projects

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "Docker how to deploy the springboot project", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "Docker how to deploy the springboot project" this article.

Create a project

Pom.xml

4.0.0 org.springframework.boot spring-boot-starter-parent 2.1.9.RELEASE com.topcheer docker 0.0.1-SNAPSHOT docker Demo project for Spring Boot 1.8 topcheer org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test test org.springframework.boot spring -boot-maven-plugin com.spotify docker-maven-plugin 1.0.0 ${docker.image.prefix} / ${project.artifactId} src/main/docker / ${project.build.directory} ${project.build.finalName} .jar

Startup class

@ SpringBootApplication@Controllerpublic class DockerApplication {public static void main (String [] args) {SpringApplication.run (DockerApplication.class, args);} @ RequestMapping ("/ user/find") @ ResponseBody public Object findUser () {Map map = new HashMap (); map.put ("name", "xdclass.net"); map.put ("age", "28"); return map;}}

Since harbor is not installed, the image cannot be pushed to the private image repository, so execute it manually first.

Mvn install, and then put the dockerfile and jar packages together

[root@topcheer docker] # ll Total usage 16452 root root root@topcheer docker-1 root root 28 14:24 Dockerfile-rw-r--r-- 1 root root 16842487 October 28 14:17 docker.jar [root@topcheer docker] # cat DockerfileFROM java:8VOLUME / tmpADD docker.jar app.jarRUN bash-c 'touch / app.jar'EXPOSE 8080ENTRYPOINT ["java", "- Djava.security.egd=file:/dev/./urandom", "- jar", "/ app.jar"] [root@topcheer docker] #

Compile into a mirror image and start

[root@topcheer docker] # docker build-f Dockerfile-t boot .Sending build context to Docker daemon 16.85 MBStep 1 MBStep 6: FROM java:8-- > d23bdf5b1b1bStep 2 MBStep 6: VOLUME / tmp-- > Running in 35037b5a7791-- > e96b96457c78Removing intermediate container 35037b5a7791Step 3 MBStep 6: ADD docker.jar app.jar-- > 06bcfdcff437Removing intermediate container 2e2e5e559ae4Step 4 Lash 6: RUN bash-c 'touch / app.jar'-- > Running in 16441febc271-- > 1779caa23f77Removing intermediate container 16441febc271Step 5 d23bdf5b1b1bStep 6: EXPOSE 8080 > Running in 14dd752ce247-- > 505044f5cdf8Removing intermediate container 14dd752ce247Step 6 MBregistry.cn-hangzhou.aliyuncs.com: ENTRYPOINT java-Djava.security.egd=file:/dev/./urandom-jar / app.jar-- > Running in 832e4ca95dd2-- > 1cb7bd139478Removing intermediate container 832e4ca95dd2Successfully built 1cb7bd139478 [root@topcheer docker] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEboot latest 1cb7bd139478 About a minute ago 677 MBregistry.cn-hangzhou.aliyuncs.com / dalianpai/topcheer zipkin 17c2bb09f482 6 days ago 154 MBdocker.io/mysql latest c8ee894bd2bd 11 days ago 456 MBelasticsearch latest 874179f19603 4 weeks ago 771 MBdocker.io/nacos/nacos-server latest a4229ac5cc19 4 weeks ago 710 MBspringbootdemo4docker latest cd13bc7f56a0 5 weeks ago 678 MBdocker.io/tomcat Latest ee48881b3e82 6 weeks ago 506 MBdocker.io/rabbitmq latest a00bc560660a 6 weeks ago 147 MBdocker.io/centos latest 67fa590cfc1c 2 months ago 202 MBdocker.io/redis latest f7302e4ab3a8 2 months ago 98.2 MBdocker.io/rabbitmq 3.7.16-management 3f92e6354d11 3 months ago 177MBdocker.io/elasticsearch 6.8.0 d0b291d7093b 5 months ago 895 MBdocker.io/hello-world latest fce289e99eb9 10 months ago 1.84 kBdocker.io/java 8 d23bdf5b1b1b 2 years ago 643 MB [root@topcheer docker] # docker run-d-p 808080vis8080 boot882ff5209aa2f40972a914b901750a50320faea65100b33e57b9c8a41533ca0b

test

These are all the contents of the article "how Docker deploys the springboot Project". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report