{"action":"created","issue":{"url":"https://api.github.com/repos/weaveworks/docker-plugin/issues/12","labels_url":"https://api.github.com/repos/weaveworks/docker-plugin/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/weaveworks/docker-plugin/issues/12/comments","events_url":"https://api.github.com/repos/weaveworks/docker-plugin/issues/12/events","html_url":"https://github.com/weaveworks/docker-plugin/issues/12","id":82400162,"number":12,"title":"Register endpoints(?) with weaveDNS","user":{"login":"squaremo","id":62033,"avatar_url":"https://avatars.githubusercontent.com/u/62033?v=3","gravatar_id":"","url":"https://api.github.com/users/squaremo","html_url":"https://github.com/squaremo","followers_url":"https://api.github.com/users/squaremo/followers","following_url":"https://api.github.com/users/squaremo/following{/other_user}","gists_url":"https://api.github.com/users/squaremo/gists{/gist_id}","starred_url":"https://api.github.com/users/squaremo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/squaremo/subscriptions","organizations_url":"https://api.github.com/users/squaremo/orgs","repos_url":"https://api.github.com/users/squaremo/repos","events_url":"https://api.github.com/users/squaremo/events{/privacy}","received_events_url":"https://api.github.com/users/squaremo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-05-29T12:04:05Z","updated_at":"2015-05-29T13:07:58Z","closed_at":null,"body":"At present the driver is not told either of the containerID or the hostname, so it is more or less impossible in remote driver terms to register containers with weaveDNS. I've filed https://github.com/docker/libnetwork/issues/234 to try and remedy the situation.\r\n\r\nAnother solution might be to watch the docker event stream for containers starting, and inspect them for weave endpoints. Of course, one problem there is that adding an endpoint to a container after the fact will not get reported in the event stream.\r\n\r\nOnce we know about a container, though, we can look it up by its SandboxKey, so perhaps that will be helpful; however, a container is not given a sandbox key until it is started."},"comment":{"url":"https://api.github.com/repos/weaveworks/docker-plugin/issues/comments/106798665","html_url":"https://github.com/weaveworks/docker-plugin/issues/12#issuecomment-106798665","issue_url":"https://api.github.com/repos/weaveworks/docker-plugin/issues/12","id":106798665,"user":{"login":"squaremo","id":62033,"avatar_url":"https://avatars.githubusercontent.com/u/62033?v=3","gravatar_id":"","url":"https://api.github.com/users/squaremo","html_url":"https://github.com/squaremo","followers_url":"https://api.github.com/users/squaremo/followers","following_url":"https://api.github.com/users/squaremo/following{/other_user}","gists_url":"https://api.github.com/users/squaremo/gists{/gist_id}","starred_url":"https://api.github.com/users/squaremo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/squaremo/subscriptions","organizations_url":"https://api.github.com/users/squaremo/orgs","repos_url":"https://api.github.com/users/squaremo/repos","events_url":"https://api.github.com/users/squaremo/events{/privacy}","received_events_url":"https://api.github.com/users/squaremo/received_events","type":"User","site_admin":false},"created_at":"2015-05-29T13:07:58Z","updated_at":"2015-05-29T13:07:58Z","body":"OK how about this:\r\n\r\nWe want to add a DNS entry `IP->hostname` when a container with `hostname` is 1. started with weave as its network, and given an endpoint with `IP`; 2. a running container with `hostname` is given an endpoint with `IP`.\r\n\r\nWhen an endpoint is created we supply its IP. When it is \"joined\" to a container, we find out the sandbox key, so we now have EndpointID->IP, and SandboxKey->EndpointID. Given SandboxKey->Container, we have (transitively) EndpointID->Container, and we can go and look at the hostname to add it to DNS.\r\n\r\nHow do we get SandboxKey->Container? We can see containers starting via the event stream, so we could go look at each to see its sandbox key. If the container has a name, and there's an entry for that sandbox key in SandboxKey->EndpointID, we know to register it with DNS.\r\n\r\nFor 2), if a container is given an endpoint while it's running, we will see the Join operation and already have an entry in SandboxKey->Container, so we'll know to go look for its hostname (in fact we could just store the hostname there).\r\n\r\nRecovery: we'll need to get the SandboxKey->Container map on startup, since we won't necessarily see containers that are already running otherwise. If we restart while docker is still running, we *may* be able to recover endpointIDs from the containers as well."}}