Minimal steps-Docker deploys the Spring Cloud project and registers it to the Eureka registry

Docker deploys the Spring Cloud project and registers it to the Eureka registry

The deployment steps of each microservice are roughly the same. Generally speaking, they are just a few steps. If there are errors, I hope to correct them. This article will deploy other microservices on the premise that Eureka has been deployed in advance. The deployment of Eureka is better than the following Is simpler, the steps will be added later

1. Check Eureka's ip

Insert picture description here

2. Change the address of the registry in the microservice configuration file

Insert picture description here

If the configuration file is on git, remember to change it

3. Type into a jar package and transfer to the virtual machine

Insert picture description here

Insert picture description here

Right click-Show In Explorer, open the file location, and find the jar package

Insert picture description here

Use SecureFXPortable software to move the jar to the virtual machine

Insert picture description here

4. Create and edit the dockerfile file in the directory where the jar package is located

FROM java:8
MAINTAINER vernhe <[email protected]>

ADD BillService.jar app.jar

CMD ["java","-jar","app.jar"]

Explain the above statement: the parent image is java:8, set the pre-signature and mailbox, add the jar package to the image, and name it app.jar, execute the java jar app.jar command to start the project.

5. Package into a mirror

Insert picture description here

6. Create a container and run

Insert picture description here

7. Enter the Eureka registration center to view

After the container is created, it may take about 1 minute to see it in the Eureka registry
Insert picture description here

8. You may encounter problems that cannot be viewed due to firewall

May be the cause of the firewall

Solution:

  1. View firewall status

    firewall-cmd --state
    
  2. If it is running, specify the port that needs to be opened, which --permanetmeans permanent effect, if you don’t want it, you can leave it alone

    firewall-cmd --permanent --zone=public --add-port=8080/tcp
    
  3. Restart firewall

    firewall-cmd --reload 
    
  4. View open ports

    firewall-cmd --permanent --zone=public --list-ports
    
  5. Visit again with external browser, display interface

Guess you like

Origin blog.csdn.net/weixin_44829930/article/details/108478654