# Docker image for elastic search

**URL:** <https://discuss.elastic.co/t/docker-image-for-elastic-search/56615>\
**Category:** Elasticsearch\
**Created:** [July 28, 2016, 11:15am UTC](https://discuss.elastic.co/t/docker-image-for-elastic-search/56615 "2016-07-28T11:15:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ravi\_Shanker\_Reddy](https://avatars.discourse-cdn.com/v4/letter/r/a5b964/32.png) [@Ravi\_Shanker\_Reddy](https://discuss.elastic.co/u/Ravi_Shanker_Reddy)\
**Post date:** [July 28, 2016, 11:15am UTC](https://discuss.elastic.co/t/docker-image-for-elastic-search/56615/1 "2016-07-28T11:15:56Z")

</div>

While creating a docker image for ES I downloaded 2.3.4 ES and changed my config file as below

`cluster.name: my-application node.name: ravi-1 node.master: true node.data: true network.host: 172.16.1.92 http.port: 9200 discovery.zen.ping.multicast.enabled: false`

and while bringing up its showing an error of

`[2016-07-28 10:23:16,164][INFO][node] [ravi-1] starting ... Exception in thread "main" BindTransportException[Failed to bind to [9300-9400]]; nested: ChannelException[Failed to bind to: /172.16.1.92:9400]; nested: BindException[Cannot assign requested address]; Likely root cause: java.net.BindException: Cannot assign requested address at sun.nio.ch.Net.bind0(Native Method) at sun.nio.ch.Net.bind(Net.java:433) at sun.nio.ch.Net.bind(Net.java:425) at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74) at org.jboss.netty.channel.socket.nio.NioServerBoss$RegisterTask.run(NioServerBoss.java:193) at org.jboss.netty.channel.socket.nio.AbstractNioSelector.processTaskQueue(AbstractNioSelector.java:391) at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:315) at org.jboss.netty.channel.socket.nio.NioServerBoss.run(NioServerBoss.java:42) at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108) at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)`

And if I remove the config file and run with `elasticsearch --networkhost _non_loopback__` is working fine. But why that error is coming for my config???  
Is it ok to work with `_non_loopback_` to maintain a 4 node cluster???

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [July 28, 2016, 10:54pm UTC](https://discuss.elastic.co/t/docker-image-for-elastic-search/56615/2 "2016-07-28T22:54:40Z")

</div>

Using configurations like `network.host: 172.16.1.92` is bogus. Docker containers pick IPs from a range, so how you do know this is always the correct IP? One answer would be address wildcarding. Elasticsearch does not offer address wildcarding e.g. `network.bind_host: *` so you must use something like `network.bind_host: 0.0.0.0` or `network.bind_host: 0` for this, but where behavior details (IPv4, IPv6 support) depend on the JVM implementation.

---

<div class="post-metadata">

**Author:** ![Ravi\_Shanker\_Reddy](https://avatars.discourse-cdn.com/v4/letter/r/a5b964/32.png) [@Ravi\_Shanker\_Reddy](https://discuss.elastic.co/u/Ravi_Shanker_Reddy)\
**Post date:** [August 1, 2016, 10:58am UTC](https://discuss.elastic.co/t/docker-image-for-elastic-search/56615/3 "2016-08-01T10:58:53Z")

</div>

Thanks for your answer. I found out a way for taking our ip in the docker.

When I start the ES in the docker image with some flags `--net=host` its showing

`[2016-08-01 10:54:12,454][INFO][transport] [ravi-1] publish_address {172.16.1.92:9300}, bound_addresses {172.16.1.92:9300}`  
`[2016-08-01 10:54:15,572][INFO][http] [ravi-1] publish_address {172.16.1.92:9200}, bound_addresses {172.16.1.92:9200}`

Now its taking the IP as I mentioned. But is this the correct way to mention IP or any other better ways. I want to maintain cluster a cluster of 4 nodes. Please suggest a best method to mention IP in the docker image

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [August 1, 2016, 5:10pm UTC](https://discuss.elastic.co/t/docker-image-for-elastic-search/56615/4 "2016-08-01T17:10:56Z")

</div>

> Is it ok to work with `_non_loopback_` to maintain a 4 node cluster???

I don't see why it would be a problem.

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [August 1, 2016, 5:23pm UTC](https://discuss.elastic.co/t/docker-image-for-elastic-search/56615/5 "2016-08-01T17:23:42Z")

</div>

I think you mean --network.host=`hostname` because --net=host does not work here.

In the case of using `hostname`, you depend on the Docker container `/etc/hostname` setting up a working network, i.e. copying the `/etc/hosts` from the Docker daemon host and a working `/etc/resolv.conf`. Fortunately Docker is doing this behind the scenes at start of a container, e.g. pre-populating DNS resolver with Google's DNS resolver. But that can be overridden by anyone who starts a container.

On the other hand, binding to wildcard interface `0.0.0.0` does not depend on any Docker network setup, it "just works"(tm).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:31pm UTC](https://discuss.elastic.co/t/docker-image-for-elastic-search/56615/6 "2017-07-05T22:31:06Z")

</div>


