Spring Cloud部署篇2——Docker Compose部署至CentOS云服务器
version: '3'
services:
eureka-server:
image: openjdk:8-jre
container_name: eureka-server
environment:
- JAVA_OPTS=-Dspring.profiles.active=eureka-server -Deureka.instance.hostname=eureka-server
ports:
- "8761:8761"
networks:
- net-spring-cloud
volumes:
- ./eureka-server:/app
command: >
java -jar /app/eureka-server.jar
zuul-server:
image: openjdk:8-jre
container_name: zuul-server
environment:
- JAVA_OPTS=-Dspring.profiles.active=zuul-server -Deureka.instance.hostname=zuul-server
ports:
- "5555:5555"
networks:
- net-spring-cloud
volumes:
- ./zuul-server:/app
command: >
java -jar /app/zuul-server.jar
auth-server:
image: openjdk:8-jre
container_name: auth-server
environment:
- JAVA_OPTS=-Dspring.profiles.active=auth-server -Deureka.instance.hostname=auth-server
ports:
- "9999:9999"
networks:
- net-spring-cloud
volumes:
- ./auth-server:/app
command: >
java -jar /app/auth-server.jar
networks:
net-spring-cloud:
driver: bridge
这个Docker Compose文件定义了一个由Eureka Server、Zuul Server和Auth Server组成的微服务架构的服务网络。它为每个服务指定了镜像、容器名、环境变量、端口映射、卷挂载和启动命令。这个文件使用了YAML格式,适用于Docker Compose版本3。在这个例子中,我们使用了OpenJDK 8的官方镜像,并且为每个服务指定了应用的配置文件和主机名。这个配置文件可以作为在CentOS云服务器上部署Spring Cloud微服务的参考。
评论已关闭