我是码头工作者的初学者,而且我无法使用docker compose让两个容器进行通信。 我有两个容器:
所有工作都没有码头工作! 现在使用docker-compose,网关无法找到Eureka服务器URL。
docker-compose.yml文件:
version: '3.5'
services:
gateway:
build:
context: ../robots-store-gateway
dockerfile: Dockerfile
image: robots-store-gateway
ports:
- 8000:8000
networks:
- robots-net
serviceregistry:
build:
context: ../robots-sotre-serviceregistry
image: robots-sotre-serviceregistry
ports:
- 8761:8761
networks:
- robots-net
networks:
robots-net:
name: custom_network
driver: bridge
网关的application.yml文件是:
eureka:
client:
service-url:
default-zone: http://serviceregistry:8761/eureka/
我收到此例外:
com.sun.jersey.api.client.ClientHandlerException:java.net.ConnectException: 连接被拒绝(连接被拒绝)
我尝试了不同的方法配置Eureka客户端,但没办法!它没有用。 提前谢谢。
答案 0 :(得分:0)
我不知道为什么!!!但最后,这对我有用:
version: '3.5'
services:
gateway:
container_name: gateway
build:
context: ../robots-store-gateway
dockerfile: Dockerfile
image: robots-store-gateway
ports:
- 8000:8000
hostname: gateway
environment:
eureka.client.serviceUrl.defaultZone: http://serviceregistry:8761/eureka/
serviceregistry:
container_name: serviceregistry
build:
context: ../robots-sotre-serviceregistry
image: robots-sotre-serviceregistry
ports:
- 8761:8761
hostname: serviceregistry
environment:
eureka.client.serviceUrl.defaultZone: http://serviceregistry:8761/eureka/
答案 1 :(得分:-1)