{"action":"created","comment":{"url":"https://api.github.com/repos/docker/docker/pulls/comments/39934569","id":39934569,"diff_hunk":"@@ -629,6 +630,38 @@ would be 2*300M, so processes can use 300M swap memory as well.\n We set both memory and swap memory, so the processes in the container can use\n 300M memory and 700M swap memory.\n \n+For memory reservation, it's kind of memory soft limit, it allows for greater","path":"docs/reference/run.md","position":12,"original_position":12,"commit_id":"9358b46f09b9482e85ceb4f4e2d62ae8d6f5d70d","original_commit_id":"9358b46f09b9482e85ceb4f4e2d62ae8d6f5d70d","user":{"login":"moxiegirl","id":1347209,"avatar_url":"https://avatars.githubusercontent.com/u/1347209?v=3","gravatar_id":"","url":"https://api.github.com/users/moxiegirl","html_url":"https://github.com/moxiegirl","followers_url":"https://api.github.com/users/moxiegirl/followers","following_url":"https://api.github.com/users/moxiegirl/following{/other_user}","gists_url":"https://api.github.com/users/moxiegirl/gists{/gist_id}","starred_url":"https://api.github.com/users/moxiegirl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moxiegirl/subscriptions","organizations_url":"https://api.github.com/users/moxiegirl/orgs","repos_url":"https://api.github.com/users/moxiegirl/repos","events_url":"https://api.github.com/users/moxiegirl/events{/privacy}","received_events_url":"https://api.github.com/users/moxiegirl/received_events","type":"User","site_admin":false},"body":"@hqhq Thanks for the contribution.  Some of the sentence constructions need to be tightened or are ESL.  So,\r\n\r\n---> https://gist.github.com/moxiegirl/189c6c7e682c75130edd\r\n\r\nMemory reservation is a kind of memory soft limit that allows for greater\r\nsharing of memory. Under normal circumstances, containers can  use as much of\r\nthe memory as needed and are constrained only by the hard limits set with the\r\n`-m`/`--memory` option. When memory reservation is set, Docker detects memory\r\ncontention or low memory and forces containers to restrict their consumption to\r\na reservation limit.\r\n\r\nAlways set the memory reservation value below the hard limit, otherwise the hard\r\nlimit takes precedence. A reservation of 0 is the same as setting no\r\nreservation. By default (without reservation set), memory reservation is the\r\nsame as the hard memory limit.\r\n\r\nMemory reservation is a soft-limit feature and does not guarantee the limit\r\nwon't be exceeded. Instead, the feature attempts to ensure that, when memory is\r\nheavily contended for, memory is allocated based on the reservation hints/setup. \r\nThe following example limits the memory (``-m`) to 500M and sets the memory\r\nreservation to 200M.\r\n\r\n```bash\r\n$ docker run -ti -m 500M --memory-reservation 200M ubuntu:14.04 /bin/bash\r\n```\r\n\r\nUnder this configuration, when the container consumes memory more than 200M and\r\nless than 500M, the next system memory reclaim attempts to shrink container\r\nmemory below 200M.\r\n\r\nThe following example set memory reservation to 1G without a hard memory limit.\r\n\r\n```bash\r\n$ docker run -ti --memory-reservation 1G ubuntu:14.04 /bin/bash\r\n```\r\n\r\nThe container can use as much memory as it needs. The memory reservation setting\r\nensures the container doesn't consume too much memory for long time, because\r\nevery memory reclaim shrinks the container's consumption to the reservation.\r\n","created_at":"2015-09-20T21:03:51Z","updated_at":"2015-09-20T21:03:51Z","html_url":"https://github.com/docker/docker/pull/14579#discussion_r39934569","pull_request_url":"https://api.github.com/repos/docker/docker/pulls/14579","_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/comments/39934569"},"html":{"href":"https://github.com/docker/docker/pull/14579#discussion_r39934569"},"pull_request":{"href":"https://api.github.com/repos/docker/docker/pulls/14579"}}},"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/14579","id":39791476,"html_url":"https://github.com/docker/docker/pull/14579","diff_url":"https://github.com/docker/docker/pull/14579.diff","patch_url":"https://github.com/docker/docker/pull/14579.patch","issue_url":"https://api.github.com/repos/docker/docker/issues/14579","number":14579,"state":"open","locked":false,"title":"Add support for memory reservation","user":{"login":"hqhq","id":6415670,"avatar_url":"https://avatars.githubusercontent.com/u/6415670?v=3","gravatar_id":"","url":"https://api.github.com/users/hqhq","html_url":"https://github.com/hqhq","followers_url":"https://api.github.com/users/hqhq/followers","following_url":"https://api.github.com/users/hqhq/following{/other_user}","gists_url":"https://api.github.com/users/hqhq/gists{/gist_id}","starred_url":"https://api.github.com/users/hqhq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hqhq/subscriptions","organizations_url":"https://api.github.com/users/hqhq/orgs","repos_url":"https://api.github.com/users/hqhq/repos","events_url":"https://api.github.com/users/hqhq/events{/privacy}","received_events_url":"https://api.github.com/users/hqhq/received_events","type":"User","site_admin":false},"body":"Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>","created_at":"2015-07-13T09:06:15Z","updated_at":"2015-09-20T21:03:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ee3f6b9b1375634fdde262c89788508751ae3f92","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/docker/docker/pulls/14579/commits","review_comments_url":"https://api.github.com/repos/docker/docker/pulls/14579/comments","review_comment_url":"https://api.github.com/repos/docker/docker/pulls/comments{/number}","comments_url":"https://api.github.com/repos/docker/docker/issues/14579/comments","statuses_url":"https://api.github.com/repos/docker/docker/statuses/9358b46f09b9482e85ceb4f4e2d62ae8d6f5d70d","head":{"label":"hqhq:hq_add_softlimit","ref":"hq_add_softlimit","sha":"9358b46f09b9482e85ceb4f4e2d62ae8d6f5d70d","user":{"login":"hqhq","id":6415670,"avatar_url":"https://avatars.githubusercontent.com/u/6415670?v=3","gravatar_id":"","url":"https://api.github.com/users/hqhq","html_url":"https://github.com/hqhq","followers_url":"https://api.github.com/users/hqhq/followers","following_url":"https://api.github.com/users/hqhq/following{/other_user}","gists_url":"https://api.github.com/users/hqhq/gists{/gist_id}","starred_url":"https://api.github.com/users/hqhq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hqhq/subscriptions","organizations_url":"https://api.github.com/users/hqhq/orgs","repos_url":"https://api.github.com/users/hqhq/repos","events_url":"https://api.github.com/users/hqhq/events{/privacy}","received_events_url":"https://api.github.com/users/hqhq/received_events","type":"User","site_admin":false},"repo":{"id":23826530,"name":"docker","full_name":"hqhq/docker","owner":{"login":"hqhq","id":6415670,"avatar_url":"https://avatars.githubusercontent.com/u/6415670?v=3","gravatar_id":"","url":"https://api.github.com/users/hqhq","html_url":"https://github.com/hqhq","followers_url":"https://api.github.com/users/hqhq/followers","following_url":"https://api.github.com/users/hqhq/following{/other_user}","gists_url":"https://api.github.com/users/hqhq/gists{/gist_id}","starred_url":"https://api.github.com/users/hqhq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hqhq/subscriptions","organizations_url":"https://api.github.com/users/hqhq/orgs","repos_url":"https://api.github.com/users/hqhq/repos","events_url":"https://api.github.com/users/hqhq/events{/privacy}","received_events_url":"https://api.github.com/users/hqhq/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hqhq/docker","description":"Docker - the open-source application container engine","fork":true,"url":"https://api.github.com/repos/hqhq/docker","forks_url":"https://api.github.com/repos/hqhq/docker/forks","keys_url":"https://api.github.com/repos/hqhq/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hqhq/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hqhq/docker/teams","hooks_url":"https://api.github.com/repos/hqhq/docker/hooks","issue_events_url":"https://api.github.com/repos/hqhq/docker/issues/events{/number}","events_url":"https://api.github.com/repos/hqhq/docker/events","assignees_url":"https://api.github.com/repos/hqhq/docker/assignees{/user}","branches_url":"https://api.github.com/repos/hqhq/docker/branches{/branch}","tags_url":"https://api.github.com/repos/hqhq/docker/tags","blobs_url":"https://api.github.com/repos/hqhq/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hqhq/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hqhq/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/hqhq/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hqhq/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/hqhq/docker/languages","stargazers_url":"https://api.github.com/repos/hqhq/docker/stargazers","contributors_url":"https://api.github.com/repos/hqhq/docker/contributors","subscribers_url":"https://api.github.com/repos/hqhq/docker/subscribers","subscription_url":"https://api.github.com/repos/hqhq/docker/subscription","commits_url":"https://api.github.com/repos/hqhq/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/hqhq/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/hqhq/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/hqhq/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/hqhq/docker/contents/{+path}","compare_url":"https://api.github.com/repos/hqhq/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hqhq/docker/merges","archive_url":"https://api.github.com/repos/hqhq/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hqhq/docker/downloads","issues_url":"https://api.github.com/repos/hqhq/docker/issues{/number}","pulls_url":"https://api.github.com/repos/hqhq/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/hqhq/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/hqhq/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hqhq/docker/labels{/name}","releases_url":"https://api.github.com/repos/hqhq/docker/releases{/id}","created_at":"2014-09-09T09:03:12Z","updated_at":"2015-05-05T07:31:31Z","pushed_at":"2015-09-18T14:21:31Z","git_url":"git://github.com/hqhq/docker.git","ssh_url":"git@github.com:hqhq/docker.git","clone_url":"https://github.com/hqhq/docker.git","svn_url":"https://github.com/hqhq/docker","homepage":"http://www.docker.com","size":68240,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"docker:master","ref":"master","sha":"606c6e8f57dd32b041364af019b681cf1d44669b","user":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"repo":{"id":7691631,"name":"docker","full_name":"docker/docker","owner":{"login":"docker","id":5429470,"avatar_url":"https://avatars.githubusercontent.com/u/5429470?v=3","gravatar_id":"","url":"https://api.github.com/users/docker","html_url":"https://github.com/docker","followers_url":"https://api.github.com/users/docker/followers","following_url":"https://api.github.com/users/docker/following{/other_user}","gists_url":"https://api.github.com/users/docker/gists{/gist_id}","starred_url":"https://api.github.com/users/docker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/docker/subscriptions","organizations_url":"https://api.github.com/users/docker/orgs","repos_url":"https://api.github.com/users/docker/repos","events_url":"https://api.github.com/users/docker/events{/privacy}","received_events_url":"https://api.github.com/users/docker/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/docker/docker","description":"Docker - the open-source application container engine","fork":false,"url":"https://api.github.com/repos/docker/docker","forks_url":"https://api.github.com/repos/docker/docker/forks","keys_url":"https://api.github.com/repos/docker/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/docker/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/docker/docker/teams","hooks_url":"https://api.github.com/repos/docker/docker/hooks","issue_events_url":"https://api.github.com/repos/docker/docker/issues/events{/number}","events_url":"https://api.github.com/repos/docker/docker/events","assignees_url":"https://api.github.com/repos/docker/docker/assignees{/user}","branches_url":"https://api.github.com/repos/docker/docker/branches{/branch}","tags_url":"https://api.github.com/repos/docker/docker/tags","blobs_url":"https://api.github.com/repos/docker/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/docker/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/docker/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/docker/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/docker/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/docker/docker/languages","stargazers_url":"https://api.github.com/repos/docker/docker/stargazers","contributors_url":"https://api.github.com/repos/docker/docker/contributors","subscribers_url":"https://api.github.com/repos/docker/docker/subscribers","subscription_url":"https://api.github.com/repos/docker/docker/subscription","commits_url":"https://api.github.com/repos/docker/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/docker/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/docker/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/docker/docker/issues/comments{/number}","contents_url":"https://api.github.com/repos/docker/docker/contents/{+path}","compare_url":"https://api.github.com/repos/docker/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/docker/docker/merges","archive_url":"https://api.github.com/repos/docker/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/docker/docker/downloads","issues_url":"https://api.github.com/repos/docker/docker/issues{/number}","pulls_url":"https://api.github.com/repos/docker/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/docker/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/docker/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/docker/docker/labels{/name}","releases_url":"https://api.github.com/repos/docker/docker/releases{/id}","created_at":"2013-01-18T18:10:57Z","updated_at":"2015-09-20T19:53:06Z","pushed_at":"2015-09-20T20:19:27Z","git_url":"git://github.com/docker/docker.git","ssh_url":"git@github.com:docker/docker.git","clone_url":"https://github.com/docker/docker.git","svn_url":"https://github.com/docker/docker","homepage":"http://www.docker.com","size":256024,"stargazers_count":24906,"watchers_count":24906,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6464,"mirror_url":null,"open_issues_count":1066,"forks":6464,"open_issues":1066,"watchers":24906,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/14579"},"html":{"href":"https://github.com/docker/docker/pull/14579"},"issue":{"href":"https://api.github.com/repos/docker/docker/issues/14579"},"comments":{"href":"https://api.github.com/repos/docker/docker/issues/14579/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/docker/pulls/14579/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/docker/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/docker/docker/pulls/14579/commits"},"statuses":{"href":"https://api.github.com/repos/docker/docker/statuses/9358b46f09b9482e85ceb4f4e2d62ae8d6f5d70d"}}}}