{"action":"created","issue":{"url":"https://api.github.com/repos/docker/docker/issues/20848","repository_url":"https://api.github.com/repos/docker/docker","labels_url":"https://api.github.com/repos/docker/docker/issues/20848/labels{/name}","comments_url":"https://api.github.com/repos/docker/docker/issues/20848/comments","events_url":"https://api.github.com/repos/docker/docker/issues/20848/events","html_url":"https://github.com/docker/docker/pull/20848","id":137784161,"number":20848,"title":"Move --rm to daemon side","user":{"login":"WeiZhang555","id":1203611,"avatar_url":"https://avatars.githubusercontent.com/u/1203611?v=3","gravatar_id":"","url":"https://api.github.com/users/WeiZhang555","html_url":"https://github.com/WeiZhang555","followers_url":"https://api.github.com/users/WeiZhang555/followers","following_url":"https://api.github.com/users/WeiZhang555/following{/other_user}","gists_url":"https://api.github.com/users/WeiZhang555/gists{/gist_id}","starred_url":"https://api.github.com/users/WeiZhang555/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WeiZhang555/subscriptions","organizations_url":"https://api.github.com/users/WeiZhang555/orgs","repos_url":"https://api.github.com/users/WeiZhang555/repos","events_url":"https://api.github.com/users/WeiZhang555/events{/privacy}","received_events_url":"https://api.github.com/users/WeiZhang555/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/docker/docker/labels/impact/api","name":"impact/api","color":"bfe5bf"},{"url":"https://api.github.com/repos/docker/docker/labels/impact/changelog","name":"impact/changelog","color":"bfe5bf"},{"url":"https://api.github.com/repos/docker/docker/labels/impact/cli","name":"impact/cli","color":"bfe5bf"},{"url":"https://api.github.com/repos/docker/docker/labels/status/2-code-review","name":"status/2-code-review","color":"fad8c7"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/docker/docker/milestones/49","html_url":"https://github.com/docker/docker/milestones/1.11.0","labels_url":"https://api.github.com/repos/docker/docker/milestones/49/labels","id":1529231,"number":49,"title":"1.11.0","description":"Code freeze / feature freeze 17 March 2016\r\nPlanned release: 7 April 2016\r\n\r\nhttps://github.com/docker/docker/wiki/Engine-1.11.0","creator":{"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},"open_issues":31,"closed_issues":64,"state":"open","created_at":"2016-01-21T01:33:46Z","updated_at":"2016-03-15T21:52:58Z","due_on":"2016-04-06T22:00:00Z","closed_at":null},"comments":52,"created_at":"2016-03-02T06:11:54Z","updated_at":"2016-03-15T21:57:48Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/20848","html_url":"https://github.com/docker/docker/pull/20848","diff_url":"https://github.com/docker/docker/pull/20848.diff","patch_url":"https://github.com/docker/docker/pull/20848.patch"},"body":"<!--\r\nPlease make sure you've read and understood our contributing guidelines;\r\nhttps://github.com/docker/docker/blob/master/CONTRIBUTING.md\r\n\r\n** Make sure all your commits include a signature generated with `git commit -s` **\r\n\r\nFor additional information on our contributing process, read our contributing\r\nguide https://docs.docker.com/opensource/code/\r\n\r\nIf this is a bug fix, make sure your description includes \"fixes #xxxx\", or\r\n\"closes #xxxx\"\r\n-->\r\n\r\nFixes #20334 \r\nFixes #16575 \r\nFixes #6003 \r\nFixes #20744 \r\nSo many related issues, I won't list them one by one.\r\n\r\n`--rm` is a client side flag which caused lots of problems:\r\n1. if client lost connection to daemon, including client crash or be killed, there's no way to clean garbage container.\r\n2. if docker stop a `--rm` container, this container won't be autoremoved.\r\n3. if docker daemon restart, container is also left over.\r\n4. bug: `docker run --rm busybox fakecmd` will exit without cleanup.\r\n\r\nIn a word, client side `--rm` flag isn't sufficient for garbage collection. Move the `--rm` flag to daemon will be more reasonable.\r\n\r\nWhat this commit do is:\r\n1. implement a `--rm` on daemon side, adding one flag `AutoRemove` into HostConfig.\r\n2. allow `run --rm -d`, no conflicting `--rm` and `-d` any more, auto-remove can work on detach mode.\r\n3. allow coexists of `--rm` and `--restart`, auto remove can work based on restart policy, container removal happens right after the moment container stops and won't restart any more.\r\n4. `docker restart` a `--rm` container will succeed, the container won't be autoremoved.\r\n5. daemon restart will cause container to be removed/kept based on restart policy, no matter daemon is shut down gracefully or using triple CTRL+C.\r\n\r\nThis commit will help a lot for daemon to do garbage collection for temporary containers for short term job.\r\n\r\nSigned-off-by: Zhang Wei <zhangwei555@huawei.com>\r\n\r\n![1334551250-0](https://cloud.githubusercontent.com/assets/1203611/13522754/6115d946-e22c-11e5-9798-aea179d83100.jpg)\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/docker/docker/issues/comments/197043797","html_url":"https://github.com/docker/docker/pull/20848#issuecomment-197043797","issue_url":"https://api.github.com/repos/docker/docker/issues/20848","id":197043797,"user":{"login":"duglin","id":1944671,"avatar_url":"https://avatars.githubusercontent.com/u/1944671?v=3","gravatar_id":"","url":"https://api.github.com/users/duglin","html_url":"https://github.com/duglin","followers_url":"https://api.github.com/users/duglin/followers","following_url":"https://api.github.com/users/duglin/following{/other_user}","gists_url":"https://api.github.com/users/duglin/gists{/gist_id}","starred_url":"https://api.github.com/users/duglin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/duglin/subscriptions","organizations_url":"https://api.github.com/users/duglin/orgs","repos_url":"https://api.github.com/users/duglin/repos","events_url":"https://api.github.com/users/duglin/events{/privacy}","received_events_url":"https://api.github.com/users/duglin/received_events","type":"User","site_admin":false},"created_at":"2016-03-15T21:57:48Z","updated_at":"2016-03-15T21:57:48Z","body":"backwards compat isn't really much of an issue. There will be lots of ways to know if we want the old or new behavior - API version number, presence of `--rm`, extra params due to resize/attach being asked for....\r\n\r\nNot sure pipelining helps since I don't think we want resize or attach's response to include the container's exit code.  Nor do I think we want to force an upgrade to http/2 just for this.\r\n\r\nBut I defer to @WeiZhang555 to decide what he'd like to explore."}}