-
Notifications
You must be signed in to change notification settings - Fork 18.7k
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
Cannot access containers by hostname with Docker overlay driver in Swarm Mode #25236
Comments
@outcoldman Docker Service Discovery has always been based on the container name and not the hostname of the container. The behavior you are seeing is expected. In 1.12 with the introduction of services, the discovery works for service name as well. |
@sanimej ok, so this is what I was afraid of. Seems like a design bug then. What is the recommended way to setup replication between containers created by same service? Let's say that I want to setup replication between 3 DB instances, if I want to use
|
@outcoldman Looks like your requirement is to get the IPs of backing containers of a service. In the service discovery we add a special entry There is also an |
@sanimej ip addresses are not very helpful. What I really want is to have a way the container itself to know what hostname/address can be used by this container to be advertised. And of course I want to do that without talking to the docker daemon. I am actually a little bit confused. Docker says that it has built-in orchestration solution (see https://blog.docker.com/2016/06/docker-1-12-built-in-orchestration/), but what you are saying that it does not support pretty simple case of autoscaling replication with |
@outcoldman as you pointed out the default hostname of the container is the container short-id and it is also the network-alias and hence communication between the containers using this short-id alias should work. If it doesnt, then it is a bug and must be fixed. (I just tried it and the ping between containers using short-id works within the host but failed across the hosts. I think that is the bug that you referred to above). But, I would like to understand your use-case better. If the above bug is fixed and the containers can talk to each other using their hostname (which happens to also be the net-alias), will that satisfy your use-case ? (or) you are looking for static ways to setup hostnames for each container even when it is actually front-ended by a service concept ? |
@mavenugo yes, you are right, the bug I posted is about that. I cannot access containers in my network by the short auto-generated hostnames when containers are located not on the same swarm node.
Yes!
That actually will be useful. I mean I do not want hosts with the same hostname inside my network. But for example if I will create service with name
With consul. I have a consul cluster working in containers. Each member has an init script which register itself with consul, also I have auto bootstrap factor (3 by default), when this node see that it is third registered member - it bootstraps the replication cluster, if it sees that number is more than 3 - it adds itself to existing cluster. I guess another option can be to use zero-configuration services, like Avahi. |
@outcoldman we will get the short-id net-alias resolved. Also I guess based on your response to my question , #24973 will interest you. Regarding the self-discovery use-case, am still not clear on why you would need any other external tool when the built-in service-discovery has features like |
@mavenugo could you point on any documentation regarding which DNS queries are supported? |
@LK4D4 Fix for this issue has already been merged in libnetwork. We will have it in for 1.12.1 |
@sanimej nice, thank you! |
@outcoldman #25420 is the doc PR for 1.12 swarm mode networks. It explains the service discovery options as well. |
* Fixes moby#25236 * Fixes moby#24789 * Fixes moby#25340 * Fixes moby#25130 * Fixes moby/libnetwork#1387 * Fix external DNS responses > 512 bytes getting dropped * Fix crash when remote plugin returns empty address string * Make service LB work from self * Fixed a few race-conditions Signed-off-by: Madhu Venugopal <[email protected]>
* Fixes moby#25236 * Fixes moby#24789 * Fixes moby#25340 * Fixes moby#25130 * Fixes moby/libnetwork#1387 * Fix external DNS responses > 512 bytes getting dropped * Fix crash when remote plugin returns empty address string * Make service LB work from self * Fixed a few race-conditions Signed-off-by: Madhu Venugopal <[email protected]> (cherry picked from commit 6645ff8) Signed-off-by: Tibor Vass <[email protected]>
* Fixes moby#25236 * Fixes moby#24789 * Fixes moby#25340 * Fixes moby#25130 * Fixes moby/libnetwork#1387 * Fix external DNS responses > 512 bytes getting dropped * Fix crash when remote plugin returns empty address string * Make service LB work from self * Fixed a few race-conditions Signed-off-by: Madhu Venugopal <[email protected]>
I have the issue that the reverse lookup of the ip addresses (got by the tasks.* dns request) returns two different addresses (almost randomly). I wrote a small node script wich does the dns lookup for tasks.* and does the reverse lookup:
I have two nodes (one master, one slave) and 3 tasks (one service) running. They run in their own network (otherwise the tasks.* request fails). I get two different responses, one is the service name and the other the network-alias/short-id/hostname. But they change randomly. Why does this happen and is there a way to make this consistent? The output of the log is:
|
TL;DR with overlay network cannot access containers by hostnames located on different swarm node
Create swarm cluster with 2 nodes
Create overlay network
Start new service with
outcoldman/splunk
(nothing specific about this image, just use as an example)Wait till you will see that service will be deployed to both nodes
Do docker inspect for both containers
On container of swarm1 for example I see
So as you can see alias on network
mynetwork
should be041182c00923
If we will try to ping this host from other container by hostname
By ip address everything is fine
Lets find hostname by ip address with python
So actually
myservice.1.4nvx54kvgxzpjy15sepurr478.mynetwork
is used as hostname for network discovery, which is container name, but not the hostname!The text was updated successfully, but these errors were encountered: