# Not able to modify the /etc/hosts inside the ES container

**URL:** <https://discuss.elastic.co/t/not-able-to-modify-the-etc-hosts-inside-the-es-container/189205>\
**Category:** Elasticsearch\
**Created:** [July 6, 2019, 1:03pm UTC](https://discuss.elastic.co/t/not-able-to-modify-the-etc-hosts-inside-the-es-container/189205 "2019-07-06T13:03:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bubunia\_Patra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bubunia_patra/32/44338_2.png) [@Bubunia\_Patra](https://discuss.elastic.co/u/Bubunia_Patra)\
**Post date:** [July 6, 2019, 1:03pm UTC](https://discuss.elastic.co/t/not-able-to-modify-the-etc-hosts-inside-the-es-container/189205/1 "2019-07-06T13:03:19Z")

</div>

Hi all,

I am using ES 5.6.10 and I want to add an entry to /etc/ hosts after the elasticsearch container is started and then restart the ES again. But I could not able to add any new entries to the /etc/hosts inside ES container

docker run -d -p 9200:9200 -p 9300:9300 -v /Users/test/Docker5610/elasticsearch.yml:/usr/share/elasticsearch/elasticsearch.yml \<5.6 Image Docker location\>

1. After exec to the docker container i cannot edit the /etc/hosts. I checked couple of posts but its not working. I tried with ES 7.0.0 also and container is getting restarted multiple times. I tried with --privileged option also but it did not work.

2. Where can I find the Docker files for the 5.6.10 ?

Can anybody help please as I am stuck now?

Regards  
Pradeep

---

<div class="post-metadata">

**Author:** ![Bubunia\_Patra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bubunia_patra/32/44338_2.png) [@Bubunia\_Patra](https://discuss.elastic.co/u/Bubunia_Patra)\
**Post date:** [July 8, 2019, 12:08pm UTC](https://discuss.elastic.co/t/not-able-to-modify-the-etc-hosts-inside-the-es-container/189205/2 "2019-07-08T12:08:02Z")

</div>

Any help?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 8, 2019, 12:40pm UTC](https://discuss.elastic.co/t/not-able-to-modify-the-etc-hosts-inside-the-es-container/189205/3 "2019-07-08T12:40:03Z")

</div>

> [@Bubunia\_Patra](#):
>
> I want to add an entry to /etc/ hosts

Why do you want to do that?

---

<div class="post-metadata">

**Author:** ![Bubunia\_Patra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bubunia_patra/32/44338_2.png) [@Bubunia\_Patra](https://discuss.elastic.co/u/Bubunia_Patra)\
**Post date:** [July 8, 2019, 11:54pm UTC](https://discuss.elastic.co/t/not-able-to-modify-the-etc-hosts-inside-the-es-container/189205/4 "2019-07-08T23:54:31Z")

</div>

I want to test a scenario (integration with a different tool) which requires the modification of /etc/hosts and restart elastic search service.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 9, 2019, 6:42am UTC](https://discuss.elastic.co/t/not-able-to-modify-the-etc-hosts-inside-the-es-container/189205/5 "2019-07-09T06:42:01Z")

</div>

The different tool that you mentioned should run in its own container, no?  
I mean that normally a container serves only one purpose if I'm not mistaken.

---

<div class="post-metadata">

**Author:** ![Bubunia\_Patra](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bubunia_patra/32/44338_2.png) [@Bubunia\_Patra](https://discuss.elastic.co/u/Bubunia_Patra)\
**Post date:** [July 9, 2019, 12:06pm UTC](https://discuss.elastic.co/t/not-able-to-modify-the-etc-hosts-inside-the-es-container/189205/6 "2019-07-09T12:06:16Z")

</div>

Yes. Basically let me elaborate what I am trying to do: I am trying to use open-source object storage to store ES snapshots. Currently I am having issues to resolve the DNS name when creating repo using bucket.[domain] in Elasticsearch container.ES is also deployed as container. So I am trying to test the scenario by adding the bucket lookup at /etc/hosts in ES to see that DNS resolve works or not. Can you pls help?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [July 9, 2019, 3:00pm UTC](https://discuss.elastic.co/t/not-able-to-modify-the-etc-hosts-inside-the-es-container/189205/7 "2019-07-09T15:00:52Z")

</div>

> Currently I am having issues to resolve the DNS name when creating repo using bucket.[domain] in Elasticsearch container.

I think you should solve that but not by "hacking" elasticsearch. Instead may be implement a proper DNS resolution. I'm not an expert on that field though so I might be totally wrong but I'm finding counter-intuitive to try to fix it that way.

> [@Bubunia\_Patra](#):
>
> Can you pls help?

I'm afraid I can't.

> Where can I find the Docker files for the 5.6.10 ?

Not sure for this version but here is what you can read for the `master` branch. Note that this is not the final version which is generated when you compile the project I think.  
At least that could give you an idea.

---

<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:** [August 6, 2019, 3:00pm UTC](https://discuss.elastic.co/t/not-able-to-modify-the-etc-hosts-inside-the-es-container/189205/8 "2019-08-06T15:00:57Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
