How to reduce memory usage of Elasticsearch docker container

When I run Elasticsearch docker container on my laptop, it consumes a lot of memory. It's because that Elasticsearch is developed in Java and its JVM by default consumes much memory.

Limit JVM memory

We can use environment variable ES_JAVA_OPTS to limit the memory that JVM consumes.

Here is a docker command example, memory is limited to 300MB:

docker run -e "discovery.type=single-node" --env ES_JAVA_OPTS="-Xmx300m" elasticsearch

This article is originally created by tooli.top. Please indicate the source when reprinting : https://www.tooli.top/posts/es_less_mem

Posted on 2022-04-11 Mail to author