在使用docker-compose时,应用程序不能注册为eureka
我拿着这个例子https://github.com/paulc4/microservices-demo ,我用它创build了3个docker镜像,用下面的Dockerfiles:
springdocker登记:
FROM openjdk:8-jdk-alpine VOLUME /tmp ADD target/microservice-demo-1.1.0.RELEASE.jar app.jar EXPOSE 1111 ENTRYPOINT exec java -jar /app.jar registration
springdocker账户:
FROM openjdk:8-jdk-alpine VOLUME /tmp ADD target/microservice-demo-1.1.0.RELEASE.jar app.jar EXPOSE 2222 ENTRYPOINT exec java -jar /app.jar accounts
springdocker的web:
FROM openjdk:8-jdk-alpine VOLUME /tmp ADD target/microservice-demo-1.1.0.RELEASE.jar app.jar EXPOSE 3333 ENTRYPOINT exec java -jar /app.jar web
如果我单独运行这三个图像一切正常, web
和accounts
服务注册到registration
服务(这是尤里卡registry的实现),我可以使用我的应用程序。 但是,使用docker-compose.yml
docker-compose
和以下docker-compose.yml
文件时
version: "3.4" services: registration: image: springdocker-registration ports: - "1111:1111" accounts: image: springdocker-accounts ports: - "2222:2222" links: - registration depends_on: - registration web: image: springdocker-web ports: - "3333:3333" depends_on: - registration - accounts links: - registration
服务web
和accounts
无法注册到registration
服务。 这里是应用程序的configuration文件:
登记-server.yml:
eureka: instance: hostname: localhost client: registerWithEureka: false fetchRegistry: false serviceUrl: defaultZone: http://localhost:1111/eureka/ server: port: 1111 spring: thymeleaf: enabled: false
账户-server.yml:
spring: application: name: accounts-service freemarker: enabled: false thymeleaf: cache: false prefix: classpath:/accounts-server/templates/ error: path: /error server: port: 2222 eureka: client: serviceUrl: defaultZone: http://localhost:1111/eureka instance: leaseRenewalIntervalInSeconds: 5 preferIpAddress: true
networkingserver.yml
spring: application: name: web-service freemarker: enabled: false thymeleaf: cache: false prefix: classpath:/web-server/templates/ error: path: /error eureka: client: serviceUrl: defaultZone: http://localhost:1111/eureka instance: leaseRenewalIntervalInSeconds: 5 preferIpAddress: true server: port: 3333
我可以发布docker-compose up
的完整控制台日志,但我认为这是有趣的一点:
1: ERROR RedirectingEurekaHttpClient - Request execution error com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused (Connection refused) 1: ERROR DiscoveryClient - DiscoveryClient_WEB-SERVICE/e3b5e6b3396c:web-service:3333 - was unable to refresh its cache! status = Cannot execute request on any known server com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
- 如何让JSF在Docker容器中使用spring-boot应用程序?
- 将war文件映像放入docker容器是一个好习惯吗?
- 在AWS上的Docker中Spring引导logging系统出现内存泄漏?
- 如何将创build的图像链接到docker-compose指定的命名卷?
- 如何build立一个spring启动应用程序jar的docker映像?
- 在Docker领事和Spring Boot服务 – 不注销
- docker-compose环境将覆盖jar中的variables,docker环境variables和jar中的variables如何映射?
- 如何正确构build使用Dockerfile的弹簧启动泊坞窗图像?
- docker-compose – 外部化spring application.properties