Get the App
SLTechnology News&Howtos  ›  Development  › 

Principle Analysis of docker in springboot

Shulou Source: shulou.com Published: 2022-06-01 01:06:40 09月21日 Update

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.

Tags: Containers images files directories principles analysis knowledge ports parameters multiple industry configuration different complex practical powerful necessary host content function Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia MySQL Huawei Microsoft Shulou Information