简体   繁体   中英

How do I make Eureka client to use host machine's IP instead of Docker container's IP?

I'm trying to dockerize my SpringBoot application. When the application is deployed in the docker container, it gets registered with Eureka using the docker container's IP.

I want it to get registered with the host machine's IP.

I've set eureka.instance.preferIpAddress to true . I tried ignoring the network interfaces like it is mentioned in documentation , but had no luck with it.

Is there any way to tell Eureka client to use host machine's IP?

If you start you container with --network=host , your container will have host's ip address and you wont need any additional configuration. Like docker run -it --network=host you-container ...

But consider drawbacks of this mode like lack of isolation of container, because your container will have access to host's networking.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM