{"action":"created","comment":{"url":"https://api.github.com/repos/docker/docker/pulls/comments/24315051","id":24315051,"diff_hunk":"@@ -59,6 +69,28 @@ func NewErrPortAlreadyAllocated(ip string, port int) ErrPortAlreadyAllocated {\n \t}\n }\n \n+func getPortRange() (int, int) {\n+\tconst param = \"/proc/sys/net/ipv4/ip_local_port_range\"\n+\tvar (\n+\t\tstart   = defaultPortRangeStart\n+\t\tend     = defaultPortRangeEnd\n+\t\trePorts = regexp.MustCompile(`\\d+`)\n+\t)\n+\n+\tif line, err := ioutil.ReadFile(param); err != nil {\n+\t\tlog.Errorf(\"Failed to read %s kernel parameter: %s\", param, err.Error())\n+\t} else {\n+\t\tports := rePorts.FindAllString(string(line), 2)\n+\t\tstart, _ = strconv.Atoi(ports[0])","path":"daemon/networkdriver/portallocator/portallocator.go","position":52,"original_position":52,"commit_id":"da2efceb7922dd64cb7bb7d7cca7a64464798c95","original_commit_id":"da2efceb7922dd64cb7bb7d7cca7a64464798c95","user":{"login":"miminar","id":1478803,"avatar_url":"https://avatars.githubusercontent.com/u/1478803?v=3","gravatar_id":"","url":"https://api.github.com/users/miminar","html_url":"https://github.com/miminar","followers_url":"https://api.github.com/users/miminar/followers","following_url":"https://api.github.com/users/miminar/following{/other_user}","gists_url":"https://api.github.com/users/miminar/gists{/gist_id}","starred_url":"https://api.github.com/users/miminar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miminar/subscriptions","organizations_url":"https://api.github.com/users/miminar/orgs","repos_url":"https://api.github.com/users/miminar/repos","events_url":"https://api.github.com/users/miminar/events{/privacy}","received_events_url":"https://api.github.com/users/miminar/received_events","type":"User","site_admin":false},"body":"Ok, better be on a safe side.","created_at":"2015-02-09T08:59:40Z","updated_at":"2015-02-09T08:59:40Z","html_url":"https://github.com/docker/docker/pull/10238#discussion_r24315051","pull_request_url":"https://api.github.com/repos/docker/docker/pulls/10238","_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/comments/24315051"},"html":{"href":"https://github.com/docker/docker/pull/10238#discussion_r24315051"},"pull_request":{"href":"https://api.github.com/repos/docker/docker/pulls/10238"}}},"pull_request":{"url":"https://api.github.com/repos/docker/docker/pulls/10238","id":27760014,"html_url":"https://github.com/docker/docker/pull/10238","diff_url":"https://github.com/docker/docker/pull/10238.diff","patch_url":"https://github.com/docker/docker/pull/10238.patch","issue_url":"https://api.github.com/repos/docker/docker/issues/10238","number":10238,"state":"open","locked":false,"title":"Use system's ephemeral port range for port allocation","user":{"login":"miminar","id":1478803,"avatar_url":"https://avatars.githubusercontent.com/u/1478803?v=3","gravatar_id":"","url":"https://api.github.com/users/miminar","html_url":"https://github.com/miminar","followers_url":"https://api.github.com/users/miminar/followers","following_url":"https://api.github.com/users/miminar/following{/other_user}","gists_url":"https://api.github.com/users/miminar/gists{/gist_id}","starred_url":"https://api.github.com/users/miminar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miminar/subscriptions","organizations_url":"https://api.github.com/users/miminar/orgs","repos_url":"https://api.github.com/users/miminar/repos","events_url":"https://api.github.com/users/miminar/events{/privacy}","received_events_url":"https://api.github.com/users/miminar/received_events","type":"User","site_admin":false},"body":"Resolves #10220\n\nThis PR causes docker to use system configured ephemeral port range for\nallocation of host's free ports to those exported by containers. The range is\nread from `/proc/sys/net/ipv4/ip_local_port_range` kernel parameter. If a\nnumber of running containers with exported ports exceeds the size of the range,\nthe parameter can be used to extend it.","created_at":"2015-01-21T13:45:02Z","updated_at":"2015-02-09T08:59:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6f60dd9079761be6efecf3dba6af864d81872020","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/docker/docker/pulls/10238/commits","review_comments_url":"https://api.github.com/repos/docker/docker/pulls/10238/comments","review_comment_url":"https://api.github.com/repos/docker/docker/pulls/comments/{number}","comments_url":"https://api.github.com/repos/docker/docker/issues/10238/comments","statuses_url":"https://api.github.com/repos/docker/docker/statuses/da2efceb7922dd64cb7bb7d7cca7a64464798c95","head":{"label":"miminar:ephemeral-port-range-allocation","ref":"ephemeral-port-range-allocation","sha":"da2efceb7922dd64cb7bb7d7cca7a64464798c95","user":{"login":"miminar","id":1478803,"avatar_url":"https://avatars.githubusercontent.com/u/1478803?v=3","gravatar_id":"","url":"https://api.github.com/users/miminar","html_url":"https://github.com/miminar","followers_url":"https://api.github.com/users/miminar/followers","following_url":"https://api.github.com/users/miminar/following{/other_user}","gists_url":"https://api.github.com/users/miminar/gists{/gist_id}","starred_url":"https://api.github.com/users/miminar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miminar/subscriptions","organizations_url":"https://api.github.com/users/miminar/orgs","repos_url":"https://api.github.com/users/miminar/repos","events_url":"https://api.github.com/users/miminar/events{/privacy}","received_events_url":"https://api.github.com/users/miminar/received_events","type":"User","site_admin":false},"repo":{"id":25812675,"name":"docker","full_name":"miminar/docker","owner":{"login":"miminar","id":1478803,"avatar_url":"https://avatars.githubusercontent.com/u/1478803?v=3","gravatar_id":"","url":"https://api.github.com/users/miminar","html_url":"https://github.com/miminar","followers_url":"https://api.github.com/users/miminar/followers","following_url":"https://api.github.com/users/miminar/following{/other_user}","gists_url":"https://api.github.com/users/miminar/gists{/gist_id}","starred_url":"https://api.github.com/users/miminar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/miminar/subscriptions","organizations_url":"https://api.github.com/users/miminar/orgs","repos_url":"https://api.github.com/users/miminar/repos","events_url":"https://api.github.com/users/miminar/events{/privacy}","received_events_url":"https://api.github.com/users/miminar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/miminar/docker","description":"Docker - the open-source application container engine","fork":true,"url":"https://api.github.com/repos/miminar/docker","forks_url":"https://api.github.com/repos/miminar/docker/forks","keys_url":"https://api.github.com/repos/miminar/docker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/miminar/docker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/miminar/docker/teams","hooks_url":"https://api.github.com/repos/miminar/docker/hooks","issue_events_url":"https://api.github.com/repos/miminar/docker/issues/events{/number}","events_url":"https://api.github.com/repos/miminar/docker/events","assignees_url":"https://api.github.com/repos/miminar/docker/assignees{/user}","branches_url":"https://api.github.com/repos/miminar/docker/branches{/branch}","tags_url":"https://api.github.com/repos/miminar/docker/tags","blobs_url":"https://api.github.com/repos/miminar/docker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/miminar/docker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/miminar/docker/git/refs{/sha}","trees_url":"https://api.github.com/repos/miminar/docker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/miminar/docker/statuses/{sha}","languages_url":"https://api.github.com/repos/miminar/docker/languages","stargazers_url":"https://api.github.com/repos/miminar/docker/stargazers","contributors_url":"https://api.github.com/repos/miminar/docker/contributors","subscribers_url":"https://api.github.com/repos/miminar/docker/subscribers","subscription_url":"https://api.github.com/repos/miminar/docker/subscription","commits_url":"https://api.github.com/repos/miminar/docker/commits{/sha}","git_commits_url":"https://api.github.com/repos/miminar/docker/git/commits{/sha}","comments_url":"https://api.github.com/repos/miminar/docker/comments{/number}","issue_comment_url":"https://api.github.com/repos/miminar/docker/issues/comments/{number}","contents_url":"https://api.github.com/repos/miminar/docker/contents/{+path}","compare_url":"https://api.github.com/repos/miminar/docker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/miminar/docker/merges","archive_url":"https://api.github.com/repos/miminar/docker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/miminar/docker/downloads","issues_url":"https://api.github.com/repos/miminar/docker/issues{/number}","pulls_url":"https://api.github.com/repos/miminar/docker/pulls{/number}","milestones_url":"https://api.github.com/repos/miminar/docker/milestones{/number}","notifications_url":"https://api.github.com/repos/miminar/docker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/miminar/docker/labels{/name}","releases_url":"https://api.github.com/repos/miminar/docker/releases{/id}","created_at":"2014-10-27T09:56:35Z","updated_at":"2015-02-03T07:35:19Z","pushed_at":"2015-02-04T16:39:42Z","git_url":"git://github.com/miminar/docker.git","ssh_url":"git@github.com:miminar/docker.git","clone_url":"https://github.com/miminar/docker.git","svn_url":"https://github.com/miminar/docker","homepage":"http://www.docker.com","size":40561,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"docker:master","ref":"master","sha":"fb55c0ecc6e1694e13787928ccbb6bcbec17cd00","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-02-09T08:55:54Z","pushed_at":"2015-02-09T04:05:33Z","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":133899,"stargazers_count":19043,"watchers_count":19043,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3930,"mirror_url":null,"open_issues_count":1003,"forks":3930,"open_issues":1003,"watchers":19043,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/docker/docker/pulls/10238"},"html":{"href":"https://github.com/docker/docker/pull/10238"},"issue":{"href":"https://api.github.com/repos/docker/docker/issues/10238"},"comments":{"href":"https://api.github.com/repos/docker/docker/issues/10238/comments"},"review_comments":{"href":"https://api.github.com/repos/docker/docker/pulls/10238/comments"},"review_comment":{"href":"https://api.github.com/repos/docker/docker/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/docker/docker/pulls/10238/commits"},"statuses":{"href":"https://api.github.com/repos/docker/docker/statuses/da2efceb7922dd64cb7bb7d7cca7a64464798c95"}}}}