{"action":"created","issue":{"url":"https://api.github.com/repos/wurstmeister/kafka-docker/issues/56","labels_url":"https://api.github.com/repos/wurstmeister/kafka-docker/issues/56/labels{/name}","comments_url":"https://api.github.com/repos/wurstmeister/kafka-docker/issues/56/comments","events_url":"https://api.github.com/repos/wurstmeister/kafka-docker/issues/56/events","html_url":"https://github.com/wurstmeister/kafka-docker/pull/56","id":112419479,"number":56,"title":"Using hostname to get container ip","user":{"login":"jcnnghm","id":71814,"avatar_url":"https://avatars.githubusercontent.com/u/71814?v=3","gravatar_id":"","url":"https://api.github.com/users/jcnnghm","html_url":"https://github.com/jcnnghm","followers_url":"https://api.github.com/users/jcnnghm/followers","following_url":"https://api.github.com/users/jcnnghm/following{/other_user}","gists_url":"https://api.github.com/users/jcnnghm/gists{/gist_id}","starred_url":"https://api.github.com/users/jcnnghm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcnnghm/subscriptions","organizations_url":"https://api.github.com/users/jcnnghm/orgs","repos_url":"https://api.github.com/users/jcnnghm/repos","events_url":"https://api.github.com/users/jcnnghm/events{/privacy}","received_events_url":"https://api.github.com/users/jcnnghm/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-20T17:28:59Z","updated_at":"2016-01-20T08:56:22Z","closed_at":"2016-01-20T08:56:22Z","pull_request":{"url":"https://api.github.com/repos/wurstmeister/kafka-docker/pulls/56","html_url":"https://github.com/wurstmeister/kafka-docker/pull/56","diff_url":"https://github.com/wurstmeister/kafka-docker/pull/56.diff","patch_url":"https://github.com/wurstmeister/kafka-docker/pull/56.patch"},"body":"`route` was used to extract the ip address for the container to auto-configure `KAFKA_ADVERTISED_HOST_NAME`.  Unfortunately, that didn't seem to be grabbing the correct IP.\r\n\r\nFor example, the IP for this container is `169.254.7.150`:\r\n\r\n```\r\nroot@7cd2d90c2c47:/# ifconfig\r\neth0      Link encap:Ethernet  HWaddr 02:42:a9:fe:07:96\r\n          inet addr:169.254.7.150  Bcast:0.0.0.0  Mask:255.255.240.0\r\n          inet6 addr: fe80::42:a9ff:fefe:796/64 Scope:Link\r\n          UP BROADCAST RUNNING  MTU:1500  Metric:1\r\n          RX packets:412 errors:0 dropped:0 overruns:0 frame:0\r\n          TX packets:616 errors:0 dropped:0 overruns:0 carrier:0\r\n          collisions:0 txqueuelen:0\r\n          RX bytes:41469 (41.4 KB)  TX bytes:49174 (49.1 KB)\r\n\r\nlo        Link encap:Local Loopback\r\n          inet addr:127.0.0.1  Mask:255.0.0.0\r\n          inet6 addr: ::1/128 Scope:Host\r\n          UP LOOPBACK RUNNING  MTU:65536  Metric:1\r\n          RX packets:3424 errors:0 dropped:0 overruns:0 frame:0\r\n          TX packets:3424 errors:0 dropped:0 overruns:0 carrier:0\r\n          collisions:0 txqueuelen:0\r\n          RX bytes:171348 (171.3 KB)  TX bytes:171348 (171.3 KB)\r\n```\r\n\r\nThe can be fetched using the `hostname` command really easily.\r\n\r\n```\r\nroot@7cd2d90c2c47:/# hostname -i\r\n169.254.7.150\r\n```\r\n\r\nThe existing `route` command will return the gateway, which isn't necessarily appropriate here.\r\n\r\n```\r\nroot@7cd2d90c2c47:/# route -n\r\nKernel IP routing table\r\nDestination     Gateway         Genmask         Flags Metric Ref    Use Iface\r\n0.0.0.0         169.254.1.1     0.0.0.0         UG    0      0        0 eth0\r\n169.254.0.0     0.0.0.0         255.255.240.0   U     0      0        0 eth0\r\nroot@7cd2d90c2c47:/# route -n | awk '/UG[ \\t]/{print $2}'\r\n169.254.1.1\r\n```\r\n\r\nThis is nice for when you want to run multiple kafka containers on a host, but cannot share `/var/run/docker.sock` with the container.  In that use case, it's difficult to use dynamic port assignment, but relatively easy to get the containers IP address from within the container."},"comment":{"url":"https://api.github.com/repos/wurstmeister/kafka-docker/issues/comments/173133514","html_url":"https://github.com/wurstmeister/kafka-docker/pull/56#issuecomment-173133514","issue_url":"https://api.github.com/repos/wurstmeister/kafka-docker/issues/56","id":173133514,"user":{"login":"wurstmeister","id":4301434,"avatar_url":"https://avatars.githubusercontent.com/u/4301434?v=3","gravatar_id":"","url":"https://api.github.com/users/wurstmeister","html_url":"https://github.com/wurstmeister","followers_url":"https://api.github.com/users/wurstmeister/followers","following_url":"https://api.github.com/users/wurstmeister/following{/other_user}","gists_url":"https://api.github.com/users/wurstmeister/gists{/gist_id}","starred_url":"https://api.github.com/users/wurstmeister/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wurstmeister/subscriptions","organizations_url":"https://api.github.com/users/wurstmeister/orgs","repos_url":"https://api.github.com/users/wurstmeister/repos","events_url":"https://api.github.com/users/wurstmeister/events{/privacy}","received_events_url":"https://api.github.com/users/wurstmeister/received_events","type":"User","site_admin":false},"created_at":"2016-01-20T08:56:22Z","updated_at":"2016-01-20T08:56:22Z","body":"Hi, \r\n\r\nthanks for your PR and sorry for the late reply. I've made the hostname command configurable now, so that different environments can easily be supported. (see https://github.com/wurstmeister/kafka-docker/commit/96f98f068f2f626990bc429dfc6e0a17dbb18972)\r\n\r\nThanks \r\n\r\n"}}