{"action":"created","comment":{"url":"https://api.github.com/repos/weaveworks/weave/pulls/comments/41258616","id":41258616,"diff_hunk":"@@ -804,6 +816,51 @@ dns_args() {\n     fi\n }\n \n+default_etc_hosts() {\n+    name=$1\n+    shift\n+    extra_hosts=$@\n+    echo \"# created by Weave - BEGIN\"\n+    echo \"# container hostname\"\n+    for cidr in $ALL_CIDRS ; do\n+        echo \"${cidr%/*}    $name\"\n+    done\n+    echo\n+    echo \"# static names added with --add-host\"\n+    for host in $extra_hosts ; do\n+        name=$(echo $host | cut -f1 -d\":\")\n+        ip=$(echo $host | cut -f2 -d\":\")\n+        echo \"$ip     $name\"\n+    done\n+\n+    cat <<-EOF\n+\n+# default localhost entries\n+127.0.0.1       localhost\n+::1             ip6-localhost ip6-loopback\n+fe00::0         ip6-localnet\n+ff00::0         ip6-mcastprefix\n+ff02::1         ip6-allnodes\n+ff02::2         ip6-allrouters\n+EOF\n+\n+    echo \"# created by Weave - END\"\n+}\n+\n+rewrite_etc_hosts() {\n+    hosts_path_and_name=$(docker inspect -f '{{.HostsPath}} {{.Config.Hostname}}' $CONTAINER)\n+    hosts=$(echo $hosts_path_and_name | cut -f1 -d\" \")\n+    name=$(echo $hosts_path_and_name | cut -f2 -d\" \")\n+    containers_path=$(dirname $hosts)\n+    mnt=/container\n+    mnt_hosts=$mnt/$(basename $hosts)\n+    contents=\"$(default_etc_hosts $name $@)\"\n+    docker run --rm \\\n+        -v $containers_path:$mnt \\\n+        --entrypoint=sh \\\n+        $EXEC_IMAGE -c \"echo '$contents' > $mnt_hosts && rm -f $mnt_hosts && echo '$contents' > $mnt_hosts\"","path":"weave","position":96,"original_position":96,"commit_id":"68a12867bea25a0cd5867d4d1ff53f346bcbcae8","original_commit_id":"68a12867bea25a0cd5867d4d1ff53f346bcbcae8","user":{"login":"inercia","id":1841612,"avatar_url":"https://avatars.githubusercontent.com/u/1841612?v=3","gravatar_id":"","url":"https://api.github.com/users/inercia","html_url":"https://github.com/inercia","followers_url":"https://api.github.com/users/inercia/followers","following_url":"https://api.github.com/users/inercia/following{/other_user}","gists_url":"https://api.github.com/users/inercia/gists{/gist_id}","starred_url":"https://api.github.com/users/inercia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inercia/subscriptions","organizations_url":"https://api.github.com/users/inercia/orgs","repos_url":"https://api.github.com/users/inercia/repos","events_url":"https://api.github.com/users/inercia/events{/privacy}","received_events_url":"https://api.github.com/users/inercia/received_events","type":"User","site_admin":false},"body":"No, it can't... :)","created_at":"2015-10-06T12:48:44Z","updated_at":"2015-10-06T12:48:44Z","html_url":"https://github.com/weaveworks/weave/pull/1477#discussion_r41258616","pull_request_url":"https://api.github.com/repos/weaveworks/weave/pulls/1477","_links":{"self":{"href":"https://api.github.com/repos/weaveworks/weave/pulls/comments/41258616"},"html":{"href":"https://github.com/weaveworks/weave/pull/1477#discussion_r41258616"},"pull_request":{"href":"https://api.github.com/repos/weaveworks/weave/pulls/1477"}}},"pull_request":{"url":"https://api.github.com/repos/weaveworks/weave/pulls/1477","id":46264854,"html_url":"https://github.com/weaveworks/weave/pull/1477","diff_url":"https://github.com/weaveworks/weave/pull/1477.diff","patch_url":"https://github.com/weaveworks/weave/pull/1477.patch","issue_url":"https://api.github.com/repos/weaveworks/weave/issues/1477","number":1477,"state":"open","locked":false,"title":"rewrite /etc/hosts in containers","user":{"login":"inercia","id":1841612,"avatar_url":"https://avatars.githubusercontent.com/u/1841612?v=3","gravatar_id":"","url":"https://api.github.com/users/inercia","html_url":"https://github.com/inercia","followers_url":"https://api.github.com/users/inercia/followers","following_url":"https://api.github.com/users/inercia/following{/other_user}","gists_url":"https://api.github.com/users/inercia/gists{/gist_id}","starred_url":"https://api.github.com/users/inercia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/inercia/subscriptions","organizations_url":"https://api.github.com/users/inercia/orgs","repos_url":"https://api.github.com/users/inercia/repos","events_url":"https://api.github.com/users/inercia/events{/privacy}","received_events_url":"https://api.github.com/users/inercia/received_events","type":"User","site_admin":false},"body":"Fix #1374 by rewritting `/etc/hosts` in containers.\r\n\r\n* So far we have been rewritting `/etc/hosts` only when attaching from the proxy, but we must also do it when running `weave run`.\r\n* We do not rewrite `/etc/hosts` when running `weave attach`\r\n* When rewritting hosts, we also add any extra hosts provided with `--add-host` arguments.\r\n\r\nThis PR also removes `weavehosts` and rewrites `/etc/hosts` from the `weave` script.\r\n\r\n_Note_: this branch is currently based on `experimental_docker`, so it must be rebased on `master` before merging...\r\n","created_at":"2015-09-29T11:22:44Z","updated_at":"2015-10-06T12:48:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b8259222ec40e779fe82b04e2c0b7f71588cc744","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/weaveworks/weave/pulls/1477/commits","review_comments_url":"https://api.github.com/repos/weaveworks/weave/pulls/1477/comments","review_comment_url":"https://api.github.com/repos/weaveworks/weave/pulls/comments{/number}","comments_url":"https://api.github.com/repos/weaveworks/weave/issues/1477/comments","statuses_url":"https://api.github.com/repos/weaveworks/weave/statuses/68a12867bea25a0cd5867d4d1ff53f346bcbcae8","head":{"label":"weaveworks:weave-1374","ref":"weave-1374","sha":"68a12867bea25a0cd5867d4d1ff53f346bcbcae8","user":{"login":"weaveworks","id":9976052,"avatar_url":"https://avatars.githubusercontent.com/u/9976052?v=3","gravatar_id":"","url":"https://api.github.com/users/weaveworks","html_url":"https://github.com/weaveworks","followers_url":"https://api.github.com/users/weaveworks/followers","following_url":"https://api.github.com/users/weaveworks/following{/other_user}","gists_url":"https://api.github.com/users/weaveworks/gists{/gist_id}","starred_url":"https://api.github.com/users/weaveworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weaveworks/subscriptions","organizations_url":"https://api.github.com/users/weaveworks/orgs","repos_url":"https://api.github.com/users/weaveworks/repos","events_url":"https://api.github.com/users/weaveworks/events{/privacy}","received_events_url":"https://api.github.com/users/weaveworks/received_events","type":"Organization","site_admin":false},"repo":{"id":23059575,"name":"weave","full_name":"weaveworks/weave","owner":{"login":"weaveworks","id":9976052,"avatar_url":"https://avatars.githubusercontent.com/u/9976052?v=3","gravatar_id":"","url":"https://api.github.com/users/weaveworks","html_url":"https://github.com/weaveworks","followers_url":"https://api.github.com/users/weaveworks/followers","following_url":"https://api.github.com/users/weaveworks/following{/other_user}","gists_url":"https://api.github.com/users/weaveworks/gists{/gist_id}","starred_url":"https://api.github.com/users/weaveworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weaveworks/subscriptions","organizations_url":"https://api.github.com/users/weaveworks/orgs","repos_url":"https://api.github.com/users/weaveworks/repos","events_url":"https://api.github.com/users/weaveworks/events{/privacy}","received_events_url":"https://api.github.com/users/weaveworks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/weaveworks/weave","description":"Weaving Docker containers into applications","fork":false,"url":"https://api.github.com/repos/weaveworks/weave","forks_url":"https://api.github.com/repos/weaveworks/weave/forks","keys_url":"https://api.github.com/repos/weaveworks/weave/keys{/key_id}","collaborators_url":"https://api.github.com/repos/weaveworks/weave/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/weaveworks/weave/teams","hooks_url":"https://api.github.com/repos/weaveworks/weave/hooks","issue_events_url":"https://api.github.com/repos/weaveworks/weave/issues/events{/number}","events_url":"https://api.github.com/repos/weaveworks/weave/events","assignees_url":"https://api.github.com/repos/weaveworks/weave/assignees{/user}","branches_url":"https://api.github.com/repos/weaveworks/weave/branches{/branch}","tags_url":"https://api.github.com/repos/weaveworks/weave/tags","blobs_url":"https://api.github.com/repos/weaveworks/weave/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/weaveworks/weave/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/weaveworks/weave/git/refs{/sha}","trees_url":"https://api.github.com/repos/weaveworks/weave/git/trees{/sha}","statuses_url":"https://api.github.com/repos/weaveworks/weave/statuses/{sha}","languages_url":"https://api.github.com/repos/weaveworks/weave/languages","stargazers_url":"https://api.github.com/repos/weaveworks/weave/stargazers","contributors_url":"https://api.github.com/repos/weaveworks/weave/contributors","subscribers_url":"https://api.github.com/repos/weaveworks/weave/subscribers","subscription_url":"https://api.github.com/repos/weaveworks/weave/subscription","commits_url":"https://api.github.com/repos/weaveworks/weave/commits{/sha}","git_commits_url":"https://api.github.com/repos/weaveworks/weave/git/commits{/sha}","comments_url":"https://api.github.com/repos/weaveworks/weave/comments{/number}","issue_comment_url":"https://api.github.com/repos/weaveworks/weave/issues/comments{/number}","contents_url":"https://api.github.com/repos/weaveworks/weave/contents/{+path}","compare_url":"https://api.github.com/repos/weaveworks/weave/compare/{base}...{head}","merges_url":"https://api.github.com/repos/weaveworks/weave/merges","archive_url":"https://api.github.com/repos/weaveworks/weave/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/weaveworks/weave/downloads","issues_url":"https://api.github.com/repos/weaveworks/weave/issues{/number}","pulls_url":"https://api.github.com/repos/weaveworks/weave/pulls{/number}","milestones_url":"https://api.github.com/repos/weaveworks/weave/milestones{/number}","notifications_url":"https://api.github.com/repos/weaveworks/weave/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/weaveworks/weave/labels{/name}","releases_url":"https://api.github.com/repos/weaveworks/weave/releases{/id}","created_at":"2014-08-18T05:19:07Z","updated_at":"2015-10-06T08:29:49Z","pushed_at":"2015-10-06T11:53:55Z","git_url":"git://github.com/weaveworks/weave.git","ssh_url":"git@github.com:weaveworks/weave.git","clone_url":"https://github.com/weaveworks/weave.git","svn_url":"https://github.com/weaveworks/weave","homepage":"http://weave.works","size":18138,"stargazers_count":3739,"watchers_count":3739,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":232,"mirror_url":null,"open_issues_count":159,"forks":232,"open_issues":159,"watchers":3739,"default_branch":"master"}},"base":{"label":"weaveworks:master","ref":"master","sha":"3d3b7a5672f4668458087dabe6234add7bf01b08","user":{"login":"weaveworks","id":9976052,"avatar_url":"https://avatars.githubusercontent.com/u/9976052?v=3","gravatar_id":"","url":"https://api.github.com/users/weaveworks","html_url":"https://github.com/weaveworks","followers_url":"https://api.github.com/users/weaveworks/followers","following_url":"https://api.github.com/users/weaveworks/following{/other_user}","gists_url":"https://api.github.com/users/weaveworks/gists{/gist_id}","starred_url":"https://api.github.com/users/weaveworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weaveworks/subscriptions","organizations_url":"https://api.github.com/users/weaveworks/orgs","repos_url":"https://api.github.com/users/weaveworks/repos","events_url":"https://api.github.com/users/weaveworks/events{/privacy}","received_events_url":"https://api.github.com/users/weaveworks/received_events","type":"Organization","site_admin":false},"repo":{"id":23059575,"name":"weave","full_name":"weaveworks/weave","owner":{"login":"weaveworks","id":9976052,"avatar_url":"https://avatars.githubusercontent.com/u/9976052?v=3","gravatar_id":"","url":"https://api.github.com/users/weaveworks","html_url":"https://github.com/weaveworks","followers_url":"https://api.github.com/users/weaveworks/followers","following_url":"https://api.github.com/users/weaveworks/following{/other_user}","gists_url":"https://api.github.com/users/weaveworks/gists{/gist_id}","starred_url":"https://api.github.com/users/weaveworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/weaveworks/subscriptions","organizations_url":"https://api.github.com/users/weaveworks/orgs","repos_url":"https://api.github.com/users/weaveworks/repos","events_url":"https://api.github.com/users/weaveworks/events{/privacy}","received_events_url":"https://api.github.com/users/weaveworks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/weaveworks/weave","description":"Weaving Docker containers into applications","fork":false,"url":"https://api.github.com/repos/weaveworks/weave","forks_url":"https://api.github.com/repos/weaveworks/weave/forks","keys_url":"https://api.github.com/repos/weaveworks/weave/keys{/key_id}","collaborators_url":"https://api.github.com/repos/weaveworks/weave/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/weaveworks/weave/teams","hooks_url":"https://api.github.com/repos/weaveworks/weave/hooks","issue_events_url":"https://api.github.com/repos/weaveworks/weave/issues/events{/number}","events_url":"https://api.github.com/repos/weaveworks/weave/events","assignees_url":"https://api.github.com/repos/weaveworks/weave/assignees{/user}","branches_url":"https://api.github.com/repos/weaveworks/weave/branches{/branch}","tags_url":"https://api.github.com/repos/weaveworks/weave/tags","blobs_url":"https://api.github.com/repos/weaveworks/weave/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/weaveworks/weave/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/weaveworks/weave/git/refs{/sha}","trees_url":"https://api.github.com/repos/weaveworks/weave/git/trees{/sha}","statuses_url":"https://api.github.com/repos/weaveworks/weave/statuses/{sha}","languages_url":"https://api.github.com/repos/weaveworks/weave/languages","stargazers_url":"https://api.github.com/repos/weaveworks/weave/stargazers","contributors_url":"https://api.github.com/repos/weaveworks/weave/contributors","subscribers_url":"https://api.github.com/repos/weaveworks/weave/subscribers","subscription_url":"https://api.github.com/repos/weaveworks/weave/subscription","commits_url":"https://api.github.com/repos/weaveworks/weave/commits{/sha}","git_commits_url":"https://api.github.com/repos/weaveworks/weave/git/commits{/sha}","comments_url":"https://api.github.com/repos/weaveworks/weave/comments{/number}","issue_comment_url":"https://api.github.com/repos/weaveworks/weave/issues/comments{/number}","contents_url":"https://api.github.com/repos/weaveworks/weave/contents/{+path}","compare_url":"https://api.github.com/repos/weaveworks/weave/compare/{base}...{head}","merges_url":"https://api.github.com/repos/weaveworks/weave/merges","archive_url":"https://api.github.com/repos/weaveworks/weave/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/weaveworks/weave/downloads","issues_url":"https://api.github.com/repos/weaveworks/weave/issues{/number}","pulls_url":"https://api.github.com/repos/weaveworks/weave/pulls{/number}","milestones_url":"https://api.github.com/repos/weaveworks/weave/milestones{/number}","notifications_url":"https://api.github.com/repos/weaveworks/weave/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/weaveworks/weave/labels{/name}","releases_url":"https://api.github.com/repos/weaveworks/weave/releases{/id}","created_at":"2014-08-18T05:19:07Z","updated_at":"2015-10-06T08:29:49Z","pushed_at":"2015-10-06T11:53:55Z","git_url":"git://github.com/weaveworks/weave.git","ssh_url":"git@github.com:weaveworks/weave.git","clone_url":"https://github.com/weaveworks/weave.git","svn_url":"https://github.com/weaveworks/weave","homepage":"http://weave.works","size":18138,"stargazers_count":3739,"watchers_count":3739,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":232,"mirror_url":null,"open_issues_count":159,"forks":232,"open_issues":159,"watchers":3739,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/weaveworks/weave/pulls/1477"},"html":{"href":"https://github.com/weaveworks/weave/pull/1477"},"issue":{"href":"https://api.github.com/repos/weaveworks/weave/issues/1477"},"comments":{"href":"https://api.github.com/repos/weaveworks/weave/issues/1477/comments"},"review_comments":{"href":"https://api.github.com/repos/weaveworks/weave/pulls/1477/comments"},"review_comment":{"href":"https://api.github.com/repos/weaveworks/weave/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/weaveworks/weave/pulls/1477/commits"},"statuses":{"href":"https://api.github.com/repos/weaveworks/weave/statuses/68a12867bea25a0cd5867d4d1ff53f346bcbcae8"}}}}