# Setting heap size in docker containers - can't get it to work

**URL:** <https://discuss.elastic.co/t/setting-heap-size-in-docker-containers-cant-get-it-to-work/181500>\
**Category:** Elasticsearch\
**Tags:** docker\
**Created:** [May 17, 2019, 2:01am UTC](https://discuss.elastic.co/t/setting-heap-size-in-docker-containers-cant-get-it-to-work/181500 "2019-05-17T02:01:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamiejackson](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@jamiejackson](https://discuss.elastic.co/u/jamiejackson)\
**Post date:** [May 17, 2019, 2:01am UTC](https://discuss.elastic.co/t/setting-heap-size-in-docker-containers-cant-get-it-to-work/181500/1 "2019-05-17T02:01:12Z")

</div>

I'm at a loss as to how to configure the heap in docker containers. Nothing seems to work as I'd expect:

Straightforward set to 2GB doesn't work:

```auto
$ docker run -it -e "ES_JAVA_OPTS=-Xms2g -Xms2g" docker.elastic.co/elasticsearch/elasticsearch:6.6.0
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
Error occurred during initialization of VM
Initial heap size set to a larger value than the maximum heap size

```

Straightforward set to 512MB doesn't work:

> <https://gist.github.com/jamiejackson/aca6b7327fd8711ef64c844e8d6543a3>

Commenting out the options in the stock `jvm.options` and setting doesn't work:

> <https://gist.github.com/jamiejackson/319f4a12a24222a7fa87ba8ed3ab23ea>

How do you do it?

---

<div class="post-metadata">

**Author:** ![martinr\_ubi](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@martinr\_ubi](https://discuss.elastic.co/u/martinr_ubi)\
**Post date:** [May 17, 2019, 2:42am UTC](https://discuss.elastic.co/t/setting-heap-size-in-docker-containers-cant-get-it-to-work/181500/2 "2019-05-17T02:42:37Z")

</div>

Hi,

All of your commands have the same typo.  
Xms Xms

It’s Xms Xmx, else your repeating the same thing twice which makes no sense. And you end up overiding only one of the default setting for heap size.

Further reading:  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html)

I think you also need to bypass the bootstrap check if you want to run it quickly like that in single node mode. That’s unrelated to heap size though.

[https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-cli-run-dev-mode](https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-cli-run-dev-mode)

---

<div class="post-metadata">

**Author:** ![jamiejackson](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@jamiejackson](https://discuss.elastic.co/u/jamiejackson)\
**Post date:** [May 17, 2019, 2:58am UTC](https://discuss.elastic.co/t/setting-heap-size-in-docker-containers-cant-get-it-to-work/181500/3 "2019-05-17T02:58:20Z")

</div>

Ah geez, thanks. My more complicated, real-life example didn't have that same duplication, but I'll fix my simple examples to see how that works.

Also, thanks for the tip about development mode.

---

<div class="post-metadata">

**Author:** ![martinr\_ubi](https://avatars.discourse-cdn.com/v4/letter/m/b5e925/32.png) [@martinr\_ubi](https://discuss.elastic.co/u/martinr_ubi)\
**Post date:** [May 17, 2019, 3:01am UTC](https://discuss.elastic.co/t/setting-heap-size-in-docker-containers-cant-get-it-to-work/181500/4 "2019-05-17T03:01:42Z")

</div>

BTW just realized my links are for the wrong version based your first command.  
Do check the right doc, I don’t want to waste your time if something you read in there varies per versions or was updated.

---

<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:** [June 14, 2019, 3:01am UTC](https://discuss.elastic.co/t/setting-heap-size-in-docker-containers-cant-get-it-to-work/181500/5 "2019-06-14T03:01:44Z")

</div>

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