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
2. Change the address of the registry in the microservice configuration file
If the configuration file is on git, remember to change it
3. Type into a jar package and transfer to the virtual machine
Right click-Show In Explorer, open the file location, and find the jar package
Use SecureFXPortable software to move the jar to the virtual machine
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
6. Create a container and run
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
8. You may encounter problems that cannot be viewed due to firewall
May be the cause of the firewall
Solution:
-
View firewall status
firewall-cmd --state
-
If it is running, specify the port that needs to be opened, which
--permanet
means permanent effect, if you don’t want it, you can leave it alonefirewall-cmd --permanent --zone=public --add-port=8080/tcp
-
Restart firewall
firewall-cmd --reload
-
View open ports
firewall-cmd --permanent --zone=public --list-ports
-
Visit again with external browser, display interface