The use substantially Docker - Application of the packaged mirror image Spring Boot and Run

Step 1

Find a spring boot project can run here with a chapter-1-spring-boot-quickstart-1.0.jarspringboot project can run
(here I use the cloud service Ali lightweight application server)
to prepare a Dockerfilefile

FROM java:8-alpine
ADD chapter-1-spring-boot-quickstart-1.0.jar springboot.jar
EXPOSE 8090
ENTRYPOINT ["java","-jar","/springboot.jar"]

Description:

  • FROM Specifies the source base image composed of a mirror, such as the project to rely jdk environment (8-alpine version of java representatives)
    can be found on the official websitehttps://hub.docker.com
  • ADD copied to the local file system file of the target vessel ( chapter-1-spring-boot-quickstart-1.0.jarthe representative file, springboot.jarrepresentative of a target file to be generated)
  • External port EXPOSE container map (of course, when the back of the container may be specified at runtime mirror)
  • ENTRYPOINT container configuration command is executed after startup, the third parameter springboot.jarto the second parameter and the rear consistent ADD

Step 2

The two documents prepared by the above: chapter-1-spring-boot-quickstart-1.0.jar, Dockerfileuploaded to the linux server

6375303-f401f2a8f712967c.png
image.png

Step 3

Input docker build -t springboot .to build the image
Note: springbootthe future generation of image name, .but also do not forget

[root@izwz91m0zmp2dlo94i0ptoz lee]# docker build -t springboot .
Sending build context to Docker daemon 14.33 MB
Step 1/4 : FROM java:8-alpine
 ---> 3fd9dd82815c
Step 2/4 : ADD chapter-1-spring-boot-quickstart-1.0.jar springboot.jar
 ---> 9c368d9d6266
Removing intermediate container b9221d4ec497
Step 3/4 : EXPOSE 8090
 ---> Running in f6aef702d0b4
 ---> dc580028919c
Removing intermediate container f6aef702d0b4
Step 4/4 : ENTRYPOINT java -jar /springboot.jar
 ---> Running in 80f0e8c17027
 ---> e33afac4394a
Removing intermediate container 80f0e8c17027
Successfully built e33afac4394a

You can see the success of the last generation of the mirror can also docker imagesview to:

6375303-d9145fe62b5f5465.png
image.png

Step 4

Run-time image as container


6375303-be930ffb4ccd49c5.png
image.png

Step 5

Browser access


6375303-474c2906bf8d1092.png
image.png

47.107.226.177This is an external address my Ali cloud server, which is the local address of the machine docker

This post is simple, this is the basis for the use of a combination of springboot and docker, please correct me if wrong, we learn together

If there are not very familiar with the command of the Docker, please refer to another article I Bowen: the basic use of Docker

Guess you like

Origin blog.csdn.net/weixin_33916256/article/details/90855901
Recommended