A quick google search turned up with: https://github.com/ruudud/devdns this might be able to fix your problem?
Another very different solutions might be to use a service registry which you could always have running in your docker infrastructure while you run your services wherever. Documentation for using a service registry with spring: https://spring.io/guides/gs/service-registration-and-discovery. (There should be similar solutions out there for most of the bigger ecosystems.)