New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Eureka registration prefer hostname instead of IP #2084
Comments
Could you provide your configuration? |
Eureka
client
Here discovery-eureka is the docker service name (In docker swarm you can hit the containers using the service name) and we have only one instance (container) of eureka running. |
We try and guess. What we get comes from java's |
If the hostname is available as an env var (say |
Thank you! @spencergibb for mentioning setting the environment variable. By setting the environment variable it's working exactly as I needed. I am setting the environment variable at the run time of the container using a shell script as the ENTRYPOINT in Dockerfile, the shell script sets the hostname environment variable and starts the jar. |
@dhanvi setting
in the docker-compose make the client register with hostname. This worked independent of any eureka setting in the application configuration. When scaling this works with dynamically generated hostname from swarm. |
@saadlu yep seen your solution before, I have also updated my answer https://stackoverflow.com/a/45233417/3514300 to reflect the same. |
Hey, seems setting eureka.instance.hostname=mydomain.com is not working for me, both my server and client service running on two different docker containers in side two different machines on aws with different public IP. Any help is much appreciated. |
@msalmanST what networking are you using ? did you try host networking type network ? https://docs.docker.com/network/host/ |
@dhanvi yes, I am using network_mode host for container networking. |
I take more time for this but not resolved now, I have uaa, registry in server IP 192.168.1.2 and micro service in 192.168.1.3. When I go to registry see Application Instances and click to micro service and working but when we login received message: "detail": "No instances available for 192.168.1.2 |
@phongphuphang0107 please ask on stack overflow or gitter. |
Is there a way for eureka to register via hostname instead of IP, I have tried setting eureka.instance.preferIpAddress to false but it takes hostname some times and IP address sometime. Related stackoverflow Question
Using hostname is useful when running micro services with docker swarm, as docker-id (which is same as hostname of the container) of the container is resolvable to all the containers (even if the containers are on different nodes/VM's)
I am aware of setting preferIpAddress as true and ignoring networks but I am looking for a straight forward solution.
Thanks in Advance.
The text was updated successfully, but these errors were encountered: