aacebedo / dnsdock

DNS service discovery for Docker containers
MIT License
607 stars 92 forks source link

Problem with name resolution when container is up and down periodically #85

Closed wclr closed 7 years ago

wclr commented 7 years ago

Following #84 issue. There is also such issue with short leaving (or periodically leaving dying containers). My use case is that I use docker for development and dev containers for project may often go up and down.

When containers is up dnsdock adds its name to DNS table, and when it is down it removes it. The problem occurs when I try to access container (by dns name, usually inside the browser) at the moment when container being down (some times it happens - I either may forget to start it, or it is just starting but not yet). In this case dnsdock forwards request to external server and may return response from forwared request - which will contain some external IP or responses that DNS record for name is not found .

In this case if dns client got a response that there is no dns record found even if containers is up now, I still will not be able not access it because dns client will not try to resolve it any more. The same problem with returned external IP (it will try to resolve only after TTL of external response). To make dns client make request again I need to flush client's dsn cache.

TTL setting may be a save for some cases, but only if containers IP is not changing, because if it is we have the same issue as with external IP, need to way for TTL before next request.

So I see possible solution as following: for certain dns request if not found in table dnsdock should response with timeout, so that client would have to make requests until it resolves it, maybe there is some more sensible solution.

aacebedo commented 7 years ago

Hi I've fixed this issue by adidng new flags called --forcettl --all --all will force dnsdock to process stopped containers so while your containers restarts DNS requests won't be forwarded to external servers. --forcettl will force the TTL for forwarded response so your client can flush the cache with a ttl=0 even if the response is comihg from an external server..

wclr commented 7 years ago

Ok thanks will see how it will work out. Have you published it on docker hub? There is last version v1.16.1-amd64 (6 days ago)?

aacebedo commented 7 years ago

it is on the develop branch you can build it to test it. I'll release it officially a little bit later

wclr commented 7 years ago

@aacebedo it seems that this problem persists in recently published v1.16.3, is it supposed to be fixed? Maybe reopen the issue?