{"action":"created","issue":{"url":"https://api.github.com/repos/docker/compose/issues/1591","labels_url":"https://api.github.com/repos/docker/compose/issues/1591/labels{/name}","comments_url":"https://api.github.com/repos/docker/compose/issues/1591/comments","events_url":"https://api.github.com/repos/docker/compose/issues/1591/events","html_url":"https://github.com/docker/compose/issues/1591","id":90199122,"number":1591,"title":"`up` command link dependencies seem reversed when restarting","user":{"login":"dcosson","id":708904,"avatar_url":"https://avatars.githubusercontent.com/u/708904?v=3","gravatar_id":"","url":"https://api.github.com/users/dcosson","html_url":"https://github.com/dcosson","followers_url":"https://api.github.com/users/dcosson/followers","following_url":"https://api.github.com/users/dcosson/following{/other_user}","gists_url":"https://api.github.com/users/dcosson/gists{/gist_id}","starred_url":"https://api.github.com/users/dcosson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcosson/subscriptions","organizations_url":"https://api.github.com/users/dcosson/orgs","repos_url":"https://api.github.com/users/dcosson/repos","events_url":"https://api.github.com/users/dcosson/events{/privacy}","received_events_url":"https://api.github.com/users/dcosson/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-06-22T20:11:25Z","updated_at":"2015-07-15T11:54:46Z","closed_at":null,"body":"I've wondered about this for a while and haven't been able to find an explanation. If I have a simple docker-compose.yml file that looks like the following:\r\n\r\n```\r\nfoo:\r\n  image: ubuntu:precise\r\n  command: sleep 3600\r\n  links:\r\n    - bar\r\nbar:\r\n  image: ubuntu:precise\r\n  command: sleep 3600\r\n  expose: \r\n    - 8000\r\n```\r\n\r\nIf they are both already running and then I restart foo with  `docker-compose up -d foo`, it will recreate foo & bar. If I do `docker-compose up -d bar` it will recreate just bar.\r\n\r\nThis seems like the opposite behavior of what I'd expect. If I restart bar, it might be at a different IP address (or different port if I have edited the exposed port), so foo should also be restarted since the linked env variables like `$BAR_PORT` might now be wrong. If I restart foo, presumably bar is still running fine so why do I need to wait for it to restart before foo restarts?\r\n\r\nIs this behavior intentional? I might just be missing something"},"comment":{"url":"https://api.github.com/repos/docker/compose/issues/comments/121591811","html_url":"https://github.com/docker/compose/issues/1591#issuecomment-121591811","issue_url":"https://api.github.com/repos/docker/compose/issues/1591","id":121591811,"user":{"login":"aanand","id":1062,"avatar_url":"https://avatars.githubusercontent.com/u/1062?v=3","gravatar_id":"","url":"https://api.github.com/users/aanand","html_url":"https://github.com/aanand","followers_url":"https://api.github.com/users/aanand/followers","following_url":"https://api.github.com/users/aanand/following{/other_user}","gists_url":"https://api.github.com/users/aanand/gists{/gist_id}","starred_url":"https://api.github.com/users/aanand/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aanand/subscriptions","organizations_url":"https://api.github.com/users/aanand/orgs","repos_url":"https://api.github.com/users/aanand/repos","events_url":"https://api.github.com/users/aanand/events{/privacy}","received_events_url":"https://api.github.com/users/aanand/received_events","type":"User","site_admin":false},"created_at":"2015-07-15T11:54:45Z","updated_at":"2015-07-15T11:54:45Z","body":"@rws-github You can use `docker-compose up --no-deps SERVICE` to stop Compose from automatically recreating dependencies.\r\n\r\n@dcosson I agree that the current behaviour is confusing. It stems from the expectation of `docker-compose up foo` to mean \"spin up `foo` and anything else it depends on\", but it's reasonable to expect the flow of triggered actions to go in the other direction, for the reasons you've laid out.\r\n\r\nTwo things are happening that'll make this less of an issue:\r\n\r\n1. The `--x-smart-recreate` flag in Compose 1.3 tells it to only recreate containers for services whose configuration or image tag has changed. This will eventually become the default behaviour.\r\n\r\n2. Links are being deprecated in favour of networks - see #1676 - which will both reduce the number of hard dependencies between services and make them resilient to containers being recreated.\r\n"}}