This article describes how Docker deploits the SpringBoot project.

Prerequisites:

2. Docker 3 has been installed on the machine. Jar package for deploying SpringBoot 4.Dockerfile file

Prepare Dockerfile

Create a Dockerfile:

FROM java:8 
VOLUME /tmp 
ADD dalaoyang_mgr.jar /dalaoyang.jar
ENTRYPOINT ["java"."-Djava.security.egd=file:/dev/./urandom"."-jar"."/dalaoyang.jar"]
Copy the code

Explain what needs attention

Dalaoyang_mgr. jar Is the jar package name. 3.ADD dalaoyang_Mgr. jar /dalaoyang.jar Copies the JAR to the container

Generate a Docker image

Place the Dockerfile and JAR in a folder and use the following command to generate the image, noting the last.

docker build -t dalaoyang .
Copy the code

Note: Dalaoyang is the name of the generated image.

More docker build commands can be seen in the Rookie tutorial

Take a look at the Docker image

docker images
Copy the code

In the figure, you can see that you already have a mirror named Dalaoyang

Run the Docker container

The following code

docker run -d -p 9000:9000 dalaoyang
Copy the code

Explain what needs attention

-d Background running 2. -P 9000:9000 Maps port 9000 of the Docker container to port 9000 of the server

The springBoot project deployed in the Docker container can be accessed in the browser using: server IP :9000.

Personal Website:www.dalaoyang.cn

Follow the author’s official account