gliderlabs / resolvable

Host-level DNS gateway for Docker
MIT License
315 stars 37 forks source link

Respect the domainname if set #19

Open wzrdtales opened 8 years ago

wzrdtales commented 8 years ago

Currently the domainname is ignored, if the hostname should be resolvable as 'hostname.docker' one needs to set the hostname to 'hostname.docker' and the domainname to 'docker'.

Example config:

        "Hostname": "host",
        "Domainname": "docker",

Currently needed workaround:

        "Hostname": "host.docker",
        "Domainname": "docker",
tilgovi commented 8 years ago

I don't think I understand fully. What configuration is this an example for?

wzrdtales commented 8 years ago

Docker-compose https://docs.docker.com/compose/compose-file/

tilgovi commented 8 years ago

Resolvable currently registers <name>.docker, not <hostname>.<domainname>.

What happens if you set the container name, rather than its hostname? The domain name option is not used by resolvable.

Two aliases are added by resolvable right now, <hostname> and <containername>.docker.

tilgovi commented 8 years ago

While the compose docs do talk about domainname, I don't actually see a way to set that with docker run. Instead, it seems that "under the hood" this actually just concatenates them and sets the hostname for docker run to <hostname>.<domainname>.

It seems resolvable handles this naively right now, which enables your workaround. Resolvable adds the hostname as an alias without parsing it at all.

I'm actually a little confused why your workaround doesn't result in host.docker.docker being the alias. I'll have to look at the go docker client code to see why the hostname is only the short hostname.

tilgovi commented 8 years ago

Alright, I just verified locally that resolvable only adds the short hostname, which is why your workaround functions.

Maybe it should add the full hostname of the container when it's started with one. That would resolve #20, too.

wzrdtales commented 8 years ago

that would be an option, also to note that docker-compose does everything perfectly valid. The FQDN is always composed from hostname + domainname. It is also what I originally asked for, to also respect the domain name and use the FQDN or full hostname.

wzrdtales commented 8 years ago

And about the confusion: docker-compose assumes: hosntame.domainname and automatically splits the hostname into those parts.

wzrdtales commented 8 years ago

To give a bit of an insight also:

The reason I need the hostname is that we also use docker as development environment and there is a possibility that there are different versions of containers with the same hostname. Those containers should be reachable via the hostname and not every time through the new random container name.

The problem now raises here: We unfortunately also currently have proxies in place to access the internet, thus we need to set exceptions. The approach to solve this is to assume that all docker domains end on .docker and this is the actual exception for the proxy.

The problem is that the hostname is never added as hostname.docker as this happens to the containername, the result from all of this was the workaround posted above.

lalyos commented 8 years ago

22 implements fqdn names. You can even give it a try by using lalyos/resolvable:fqdn-ptr image. See #22 comments.

Just a quick note on docker-compose: you can specify fqdn names 2 ways:

hostname can include the full domainname:

web:
    image: nginx
    hostname: myweb.example.com

Or define separate hostname and domainname:

web:
    image: nginx
    hostname: myweb
    domainname: example.com