Advanced docker: actual combat - how to run microservices developed by yourself on docker?

Through the previous series of studies, we already know how to make a dockerfile. So, in this article, we will deploy the spring boot demo project we wrote on docker.

Case goal:

How do the microservices we develop run on docker?

1: Create a new common microservice module through IDEA

2: Publish microservices through dockerfile and deploy them into docker containers

Create a microservice project

1: Create a simple version of the spring boot project. browser can access. Just return any information

2: After mvn package, upload the jar of the corresponding project to the docker host. For example, Kaige uploaded it to the mydocker folder.

 

Publish microservices into docker containers through dockerfile

1: Write dockerfile

# The basic image uses java 
FROM java:8 
# Author 
MAINTAINER kagejava 
# VOLUME specifies the temporary file directory as /tmp, creates a temporary file in the host /var/lib/docker directory and links it to the container's /tmp VOLUME /tmp 
# 
Will Add the jar package to the container and change its name to kagejava_docker.jar 
ADD docker-demo-0.0.1-SNAPSHOT.jar kagejava_docker.jar 
# Run the jar package 
RUN bash -c 'touch /kagejava_docker.jar' 
ENTRYPOINT ["java","- jar","/kagejava_docker.jar

Guess you like

Origin blog.csdn.net/kaizi_1992/article/details/128449386