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

Principle Analysis of docker in springboot

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces the relevant knowledge of "principle Analysis of docker in springboot". The editor shows you the operation process through actual cases. The operation method is simple, fast and practical. I hope this article "principle Analysis of docker in springboot" can help you solve the problem.

1. Add maven configuration

Ms4t eureka org.springframework.boot spring-boot-maven-plugin com.spotify dockerfile-maven-plugin 1.3.6 ${docker.image.prefix} / ${project.artifactId} target/$ {project.build.finalName} .jar

Second, create a Dockerfile

FROM openjdk:8-jdk-alpineVOLUME / tmpARG JAR_FILECOPY ${JAR_FILE} app.jarENTRYPOINT ["java", "- jar", "/ app.jar"]

Parameter explanation:

FROM: a basic image is required, which can be public or private.

Subsequent builds will be based on this image. If multiple images are established in the same Dockerfile, multiple FROM instructions can be used.

VOLUME configures a directory with persistence, and a temporary file is created in the host / var/lib/docker directory and linked to the container's / tmp. The modification steps are optional, which is necessary if the application of the file system is involved.

. The / tmp directory is used to persist to the Docker data folder because the embedded Tomcat container used by Spring Boot uses / tmp as the working directory by default

ARG sets the parameters added when compiling the image. ENV is the environment variable that sets the container.

COPY: only local files can be copied to the container, and ADD is more powerful but more complex.

Commands executed when the ENTRYPOINT container starts

Mirror ports exposed by EXPOSE 8080

III. Construction

Mvn install dockerfile:build

IV. Start

Docker run-d-name name-p external port: container port image ID on "principle analysis of docker in springboot" is introduced here, thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

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

Development

Wechat

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

12
Report