# Bootstrap.memory\_lock issues

**URL:** <https://discuss.elastic.co/t/bootstrap-memory-lock-issues/110108>\
**Category:** Elasticsearch\
**Created:** [December 4, 2017, 9:50am UTC](https://discuss.elastic.co/t/bootstrap-memory-lock-issues/110108 "2017-12-04T09:50:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dhrm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dhrm/32/24987_2.png) [@dhrm](https://discuss.elastic.co/u/dhrm)\
**Post date:** [December 4, 2017, 9:50am UTC](https://discuss.elastic.co/t/bootstrap-memory-lock-issues/110108/1 "2017-12-04T09:50:06Z")

</div>

I'm running ElasticSearch using Docker and I'm starting it using Docker compose with _bootstrap.memory\_lock=true_:

```
---
version: '3'
services:

  elasticsearch:
	image: docker.elastic.co/elasticsearch/elasticsearch:6.0.0
	environment:
	  - 'bootstrap.memory_lock=true'
	ports:
	  - '9200:9200'
	  - '9300:9300'

```

But I get this error:

```
[WARN][o.e.b.JNANatives] Unable to lock JVM Memory: error=12, reason=Cannot allocate memory
[WARN][o.e.b.JNANatives] This can result in part of the JVM being swapped out.
[WARN][o.e.b.JNANatives] Increase RLIMIT_MEMLOCK, soft limit: 65536, hard limit: 65536
[WARN][o.e.b.JNANatives] These can be adjusted by modifying /etc/security/limits.conf, for example:
	 # allow user 'elasticsearch' mlockall
	 elasticsearch soft memlock unlimited
	 elasticsearch hard memlock unlimited
[WARN][o.e.b.JNANatives] If you are logged in interactively, you will have to re-login for the new limits to take effect.

```

I've added the lines to the file on both my host OS (Ubuntu Server) and the into the container and I've restarted the host OS. How can I fix this issue?

---

<div class="post-metadata">

**Author:** ![Fram\_Souza](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fram_souza/32/24833_2.png) [@Fram\_Souza](https://discuss.elastic.co/u/Fram_Souza)\
**Post date:** [December 4, 2017, 12:24pm UTC](https://discuss.elastic.co/t/bootstrap-memory-lock-issues/110108/2 "2017-12-04T12:24:50Z")

</div>

Good Morning @dhrm😉

Does the instance in question use swap? In general, this option needs to be enabled only when the swap is configured on the machine.

Another option is to execute the " **swapoff**" or else use the sysctl **swapiness** to control this for you. When you enable " **bootstrap.memory\_lock**" it prevents the memory pages used by Elasticsearch from being sent to swap.

By default the memory pages have 4k, so you need to check how many pages the user has configured through ulimit -a, I assume it's 64 pages. That is 4k x 64 should be the equivalent of the amount of memory you are allocating in the heap.

To solve this you need to leave this unlimited. You can resolve this by using the **limits.conf** file or within the Elasticsearch boot file itself: " **MAX\_LOCKED\_MEMORY = unlimited**" or simply leave this commented option in elasticsearch.yml

;D  
"

---

<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:** [January 1, 2018, 12:24pm UTC](https://discuss.elastic.co/t/bootstrap-memory-lock-issues/110108/3 "2018-01-01T12:24:56Z")

</div>

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