SpringBoot is packaged into a docker image to run

1. Package springboot

Open the terminal or cmd cd to your java project folder,
execute the command as follows

mvn clean package -DskipTests

Insert picture description here

Insert picture description here

2. Write Dockerfile

First, we download a docker plugin, it gives us some hints
Insert picture description here

Create a dockerfile

FROM java:8

COPY  *.jar /app.jar

CMD ["--server.port=8080"]

EXPOSE 8080

ENTRYPOINT ["java","-jar","/app.jar"]

Insert picture description here

3. Upload the jar package and Dockerfile to the cloud server

Insert picture description here

4. Build a mirror

command:

docker build -t ybgdockertest .

Screenshot:
Insert picture description here
build completed
Insert picture description here

5. Run the mirror

command:

docker run -d -p 8003:8080 --name dockertest ybgdockertest

Test: The
Insert picture description here
operation is successful and the deployment is successful.

Guess you like

Origin blog.csdn.net/weixin_43520670/article/details/113742508