2

When using Docker swarm mode and exposing ports outside, you have at least three networks, the ingress network, the bridge network and the overlay network (used for internal cluster communications). The container joins these networks using one of eth0-2 (randomically each time) interfaces and from an application point of view is not easy to understand which of these is the cluster network (the correct one to use for service discovery client publish - e.g Spring Eureka). Is there a way to customize network interface names in some way?

Alessandro Dionisi
  • 2,494
  • 4
  • 33
  • 37

1 Answers1

1

Not a direct answer to your question, but one of the key selling points of swarm mode is the built-in service discovery mechanism, which in my opinion works really nicely.

More related, I don't think it's possible to specify the desired interface for an overlay network. However, when creating a network, it is possible to define the subnet or the IP range of the network (https://docs.docker.com/engine/reference/commandline/network_create/). You could use that to identify the interface belonging to your overlay network, by checking if the bound IP address is part of the network you want to publish on.

Ede
  • 387
  • 2
  • 10
  • 1
    For sure that could be a useful information, the problem is that Spring Eureka allows only to filter on interface name, not on the IP address. Anyway having these network interfaces having the same name and being ordered randomly doesn't help at all. – Alessandro Dionisi Mar 30 '17 at 09:41
  • Not 100% sure, but a little googling got me this https://github.com/spring-cloud/spring-cloud-netflix/issues/788 and then this https://github.com/spring-cloud/spring-cloud-commons/issues/114 which led me to believe there is a `preferredNetworks` option now, maybe that's something you use together with specifying the overlay subnet? – Ede Mar 30 '17 at 10:17
  • You are right, this has been added in a recent release. I found the correct documentation describing it [here](http://cloud.spring.io/spring-cloud-static/Camden.SR5/). I mark your answer as correct as it solves my issue, even if it doesn't cover how to rename Docker network interfaces. Thanks. – Alessandro Dionisi Mar 30 '17 at 12:48