{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker/issues/13176","labels_url":"https://api.github.com/repos/docker/docker/issues/13176/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker/issues/13176/comments","events_url":"https://api.github.com/repos/docker/docker/issues/13176/events","html_url":"https://github.com/docker/docker/issues/13176","id":75909870,"number":13176,"title":"link metadata removed when remove nested container whas restarted","user":{"login":"tclavier","id":357257,"avatar_url":"https://avatars.githubusercontent.com/u/357257?v=3","gravatar_id":"","url":"https://api.github.com/users/tclavier","html_url":"https://github.com/tclavier","followers_url":"https://api.github.com/users/tclavier/followers","following_url":"https://api.github.com/users/tclavier/following{/other_user}","gists_url":"https://api.github.com/users/tclavier/gists{/gist_id}","starred_url":"https://api.github.com/users/tclavier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tclavier/subscriptions","organizations_url":"https://api.github.com/users/tclavier/orgs","repos_url":"https://api.github.com/users/tclavier/repos","events_url":"https://api.github.com/users/tclavier/events{/privacy}","received_events_url":"https://api.github.com/users/tclavier/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-13T09:08:29Z","updated_at":"2015-05-26T12:55:52Z","closed_at":null,"body":"Description of problem:\r\nWhen we remove a container, that remove this container from links in metadata of linked containers\r\n\r\n`docker version`:\r\n```\r\nClient version: 1.6.1\r\nClient API version: 1.18\r\nGo version (client): go1.4.2\r\nGit commit (client): 97cd073\r\nOS/Arch (client): linux/amd64\r\nServer version: 1.6.1\r\nServer API version: 1.18\r\nGo version (server): go1.4.2\r\nGit commit (server): 97cd073\r\nOS/Arch (server): linux/amd64\r\n```\r\n\r\n`docker info`:\r\n```\r\nContainers: 46\r\nImages: 988\r\nStorage Driver: btrfs\r\nExecution Driver: native-0.2\r\nKernel Version: 3.16.0-4-amd64\r\nOperating System: Debian GNU/Linux stretch/sid\r\nCPUs: 4\r\nTotal Memory: 7.673 GiB\r\nName: azae02\r\nID: F3W4:FHMW:WO7H:AUPJ:SOSS:ZDPB:74L5:FCWQ:6KLV:M34Q:MK6C:23YX\r\nUsername: tclavier\r\nRegistry: [https://index.docker.io/v1/]\r\n```\r\n\r\n`uname -a`:\r\n    Linux azae02 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt9-3 (2015-04-23) x86_64 GNU/Linux\r\n\r\nEnvironment details (AWS, VirtualBox, physical, etc.):\r\nphysical, but it's true on all environments.\r\n\r\nHow reproducible:\r\nAlways \r\n\r\nSteps to Reproduce:\r\n```\r\ndocker run -d --name db deliverous/blog\r\ndocker run -d --name front --link db:db deliverous/blog\r\n\r\ndocker inspect --format '{{.HostConfig.Links}}' front\r\n[/db:/front/db]\r\n\r\ndocker stop db\r\ndocker inspect --format '{{.HostConfig.Links}}' front\r\n[/db:/front/db]\r\n\r\ndocker rm db\r\ndocker inspect --format '{{.HostConfig.Links}}' front\r\n<no value>\r\n\r\ndocker run -d --name db deliverous/blog\r\ndocker inspect --format '{{.HostConfig.Links}}' front\r\n<no value>\r\n\r\nsudo grep db /var/lib/docker/containers/b518f031659680e47410faf2b184ceb6eb8a1e201a5bfef1dcd1c4fe37264da2/hosts\r\n172.17.0.113\tdb 84fa62a731fb\r\n\r\ndocker inspect --format {{.NetworkSettings.IPAddress}} db\r\n172.17.0.115\r\n```\r\n\r\nActual Results:\r\nWe have an incoherence : \r\n- docker inspect say they are no link name DB\r\n- inside the container DB point on old IP \r\n\r\nExpected Results:\r\nI don't know what it's the good results : \r\n- no link in metadata of front container and no entry in hosts file \r\n- or link in metadata of front container and good IP in hosts file\r\n\r\nAdditional info:\r\n"},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/105516841","html_url":"https://github.com/docker/docker/issues/13176#issuecomment-105516841","issue_url":"https://api.github.com/repos/docker/docker/issues/13176","id":105516841,"user":{"login":"thaJeztah","id":1804568,"avatar_url":"https://avatars.githubusercontent.com/u/1804568?v=3","gravatar_id":"","url":"https://api.github.com/users/thaJeztah","html_url":"https://github.com/thaJeztah","followers_url":"https://api.github.com/users/thaJeztah/followers","following_url":"https://api.github.com/users/thaJeztah/following{/other_user}","gists_url":"https://api.github.com/users/thaJeztah/gists{/gist_id}","starred_url":"https://api.github.com/users/thaJeztah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thaJeztah/subscriptions","organizations_url":"https://api.github.com/users/thaJeztah/orgs","repos_url":"https://api.github.com/users/thaJeztah/repos","events_url":"https://api.github.com/users/thaJeztah/events{/privacy}","received_events_url":"https://api.github.com/users/thaJeztah/received_events","type":"User","site_admin":false},"created_at":"2015-05-26T12:55:52Z","updated_at":"2015-05-26T12:55:52Z","body":"Heh, yes Gordon can be quite a PITA, sorry for that, but he can be helpful :smile: \r\n\r\n(Part of) this is expected behavior. Links in docker are not \"dynamic\" and are established between a specific *instance* of a container, and not based on the container *name*.\r\n\r\nThis means that, when the linked container is removed, the link is removed with it, and a new container created with the same name is not automatically linked. If you need to be able to \"dynamically\" establish links, using a discovery-service might be a better approach, but requires more work.\r\n\r\nLibnetwork (https://github.com/docker/libnetwork) is currently being integrated into Docker and will add more options in the future (which will be introduced in \"experimental builds\" first). I'm not sure if this will include a discovery mechanism, but I will ask the libnetwork team.\r\n\r\nThis is largely a duplicate of this issue; https://github.com/docker/docker/issues/3155, the discussion on that issue may give some useful information as well.\r\n\r\nWhat I *do* think should change, is that the entry for the linked container should be removed from `/etc/hosts` as soon as that container is removed. I seem to remember some changes were made in that area, but I'm not entirely sure.\r\n\r\n@estesp I don't recall clearly; did you make changes so that entries were also *removed* from `/etc/hosts`?"}}