Spring EurekaClient in container can't register to EurekaServer on localhost nor EurekaServer in docker container

Spring EurekaClient in container can't register to EurekaServer on localhost nor EurekaServer in docker container



I'm developing a project using Spring Boot Cloud with Eureka. When i run everything on my machine everything works fine. But when I start using Docker:



I also have Cloud Config Server running on localhost:8888 and services in Docker container cant access it.
Tried running it all in docker-compose, docker stack, none of it works.



bootstrap.yml for Eureka Server:


spring:
application:
name: conhub-eureka-server
cloud:
config:
uri:
- http://localhost:8888
server:
port: 8761
eureka:
client:
register-with-eureka: false
fetch-registry: false



Dockerfile for Eureka server (I use fabric8 docker maven plugin):


FROM openjdk
VOLUME /tmp
ADD maven/conhub-eureka-server-0.0.1-SNAPSHOT.jar myapp.jar
RUN sh -c 'touch /myapp.jar'
EXPOSE 8761
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-
jar","/myapp.jar"]



bootstrap.yml for example service (it's a zuul gateway):


server:
port: 8765
spring:
cloud:
config:
enabled: true
uri: http://localhost:8888
application:
name: conhub-gateway
eureka:
client:
service-url:
default-zone: http://$EUREKA_SERVER_HOST:localhost:8761/eureka



Dockerfile for example service:


FROM openjdk

VOLUME /tmp
ADD maven/conhub-gateway-0.0.1-SNAPSHOT.jar myapp.jar
RUN sh -c 'touch /myapp.jar'
EXPOSE 8765
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-
jar","/myapp.jar"]



I've read many posts here and tried everything but with no success.
I guess my biggest surprise is why a service in a container can't access in my case http://localhost:8888 for configs? I can easily access it manually.



EDIT 2
Well I finally found the mistake. In a EurekaClient the proper way of writing delault zone for EurekaServer is:
defaultZone not default-zone.
Thanks to this post









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

How do I collapse sections of code in Visual Studio Code for Windows?

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ