# Understanding docker and memory settings

**URL:** <https://discuss.elastic.co/t/understanding-docker-and-memory-settings/123336>\
**Category:** Elasticsearch\
**Created:** [March 9, 2018, 8:00pm UTC](https://discuss.elastic.co/t/understanding-docker-and-memory-settings/123336 "2018-03-09T20:00:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![javadevmtl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javadevmtl/32/45613_2.png) [@javadevmtl](https://discuss.elastic.co/u/javadevmtl)\
**Post date:** [March 9, 2018, 8:00pm UTC](https://discuss.elastic.co/t/understanding-docker-and-memory-settings/123336/1 "2018-03-09T20:00:07Z")

</div>

Hi, running 6.2.2.

By default docker does not restrain the memory settings.

If we launch with...

ES\_JAVA\_OPTS=-Xms20480m -Xmx20480m  
bootstrap.memory\_lock=true

On a host with 128GB RAM will Elasticsearch running inside a docker container only use a total 40GB or will the memory mapped files try to take up as much a space as possible?

And if so should we tell docker to force the container's memory to double of the Xmx setting?

---

<div class="post-metadata">

**Author:** ![thiago](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/thiago/32/32096_2.png) [@thiago](https://discuss.elastic.co/u/thiago)\
**Post date:** [March 11, 2018, 2:25pm UTC](https://discuss.elastic.co/t/understanding-docker-and-memory-settings/123336/2 "2018-03-11T14:25:46Z")

</div>

When setting `-Xms20480m -Xmx20480m` the amount of heap assigned will be `20G` and not `40G`. Also, you should not set above `30G` due to performance reasons (see [https://www.elastic.co/blog/a-heap-of-trouble](https://www.elastic.co/blog/a-heap-of-trouble))

Lastly, keep in mind that Elasticsearch will use all available RAM. It will use OS-level memory cache to cache index files, which greatly improves performance.

---

<div class="post-metadata">

**Author:** ![javadevmtl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/javadevmtl/32/45613_2.png) [@javadevmtl](https://discuss.elastic.co/u/javadevmtl)\
**Post date:** [March 11, 2018, 2:58pm UTC](https://discuss.elastic.co/t/understanding-docker-and-memory-settings/123336/3 "2018-03-11T14:58:36Z")

</div>

Sorry for slight confusion. I am aware of the Elastic recommended mem settings. Im running Elastic with Mesos/Marathon and the assuption was that my Marathon settings where set to schedule a 40GB container at double what I have the -Xmx20G. But it doesn't unless we use the Mesos containerizer. Anyways...

I was curious how the JVM and Elastic behave inside docker regarding memory and mmap files. Since the container isn't restricted memory wise then the contaimer actually has 128GB available to it from the host.

So we have to consider that other containers includding other Elastic nodes like my coordinators are scheduled on that host. So it is possible that the containers will contend for available RAM.

The host has 128GB and 2GB swap which is pointless (need to revise the cloud image lol) and with mem\_lock settings Elastic should be ok and not swapped out.

---

<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:** [April 8, 2018, 2:59pm UTC](https://discuss.elastic.co/t/understanding-docker-and-memory-settings/123336/4 "2018-04-08T14:59:29Z")

</div>

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