6

I am running Elasticsearch inside a Docker container in Linux (Ubuntu). I am having a lot of circuit_breaking_exception problems, citing a 486.3mb limit; so I've decided to raise my JVM heap size a bit. My machine has 6 GB physical memory, so up to 3 GB should be safe for the heap size.

So I've gone to change the setting in jvm.options. The default is:

-Xms1g 
-Xmx1g

And I've changed it to:

-Xms2g 
-Xmx2g

And here comes the twist: not only I keep getting the same circuit_breaking_exception with the same size limit; echo $ES_JAVA_OPTS returns -Xmx512m -Xms512m. This is not even the default setting. I've also tried leaving the default jvm.options and creating a new user.options inside jvm.options.d, with the same result. Am I missing something? Am I doing anything wrong here?

Gorpik
  • 10,940
  • 4
  • 36
  • 56
  • Hi, can you add how you are running elasticsearch as in if you can share the Dockerfile if you are building your own image or using the official image. For the official image I am able to pass `- "ES_JAVA_OPTS=-Xms2g -Xmx2g"` as the environment variable and able to increase heap size. – karan shah Oct 06 '20 at 08:50

3 Answers3

11

As shown in the official installation of ES using docker, you can pass it as env variable

version: '2.2'
services:
  es01:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.9.2
    container_name: es01
    environment: -> it comes under environment section, removed other settings for brevity
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m" --> note this
    

You need to restart the docker container after changing this ES_JAVA_OPTS env variable value

  • 1
    Aww, it looks like I was doing just this. I'm modifying my `docker-compose.yml` and see what happens. Thanks a lot for the tip. – Gorpik Oct 06 '20 at 09:48
  • 1
    @Gorpik glad you found it useful, please don'r forget to upvote and accept the answer :D –  Oct 06 '20 at 09:58
  • 1
    I was just checking that it worked, and it did. Thanks a lot again. – Gorpik Oct 06 '20 at 10:10
  • I'm trying to do this with `-XX:-MaxFDLimit` or `-XX:+MaxFDLimit` instead of heap size and it isn't working. – Translunar Jul 13 '22 at 21:57
5

You can pass this setting to container using env var ES_JAVA_OPTS.

docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e "ES_JAVA_OPTS=-Xms2g -Xmx2g" docker.elastic.co/elasticsearch/elasticsearch:7.9.2
user2026753
  • 707
  • 7
  • 7
0

According to the documentation, in a docker environment, you have to set it in the docker-compose.yml

https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-compose-file

joelby
  • 87
  • 8
Jaycreation
  • 2,029
  • 1
  • 15
  • 30