# Can't create lock file when sharing data.path folder between docker and host

**URL:** <https://discuss.elastic.co/t/cant-create-lock-file-when-sharing-data-path-folder-between-docker-and-host/81617>\
**Category:** Elasticsearch\
**Created:** [April 7, 2017, 1:48pm UTC](https://discuss.elastic.co/t/cant-create-lock-file-when-sharing-data-path-folder-between-docker-and-host/81617 "2017-04-07T13:48:49Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mathias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mathias/32/23176_2.png) [@mathias](https://discuss.elastic.co/u/mathias)\
**Post date:** [April 7, 2017, 1:48pm UTC](https://discuss.elastic.co/t/cant-create-lock-file-when-sharing-data-path-folder-between-docker-and-host/81617/1 "2017-04-07T13:48:49Z")

</div>

My elasticsearch container works fine when using default data.path

I start it like this:  
docker run -d --rm --net=host --name=elasticsearch elasticsearch2

But when I create a folder on my host machine and share this with the docker as data.path I fails to start:

docker run -d --rm --net=host --name=elasticsearch -v "$PWD/elasticsearch/data":/usr/share/elasticsearch/data elasticsearch2

[2017-04-07T13:36:05,396][INFO][o.e.n.Node] [] initializing ...  
[2017-04-07T13:36:05,440][WARN][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]  
org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: failed to obtain node locks, tried [[/usr/share/elasticsearch/data/elasticsearch]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max\_local\_storage\_nodes] (was [1])?  
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:125) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.cli.Command.main(Command.java:88) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:89) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:82) ~[elasticsearch-5.2.2.jar:5.2.2]  
Caused by: java.lang.IllegalStateException: failed to obtain node locks, tried [[/usr/share/elasticsearch/data/elasticsearch]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max\_local\_storage\_nodes] (was [1])?  
at org.elasticsearch.env.NodeEnvironment.(NodeEnvironment.java:260) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.node.Node.(Node.java:252) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.node.Node.(Node.java:232) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.bootstrap.Bootstrap$6.(Bootstrap.java:241) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:241) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) ~[elasticsearch-5.2.2.jar:5.2.2]  
... 6 more  
Caused by: java.io.IOException: failed to obtain lock on /usr/share/elasticsearch/data/nodes/0  
at org.elasticsearch.env.NodeEnvironment.(NodeEnvironment.java:239) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.node.Node.(Node.java:252) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.node.Node.(Node.java:232) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.bootstrap.Bootstrap$6.(Bootstrap.java:241) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:241) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) ~[elasticsearch-5.2.2.jar:5.2.2]  
... 6 more  
Caused by: java.io.IOException: Mount point not found  
at sun.nio.fs.LinuxFileStore.findMountEntry(LinuxFileStore.java:91) ~[?:?]  
at sun.nio.fs.UnixFileStore.(UnixFileStore.java:65) ~[?:?]  
at sun.nio.fs.LinuxFileStore.(LinuxFileStore.java:44) ~[?:?]  
at sun.nio.fs.LinuxFileSystemProvider.getFileStore(LinuxFileSystemProvider.java:51) ~[?:?]  
at sun.nio.fs.LinuxFileSystemProvider.getFileStore(LinuxFileSystemProvider.java:39) ~[?:?]  
at sun.nio.fs.UnixFileSystemProvider.getFileStore(UnixFileSystemProvider.java:368) ~[?:?]  
at java.nio.file.Files.getFileStore(Files.java:1461) ~[?:1.8.0\_121]  
at org.elasticsearch.env.ESFileStore.getMatchingFileStore(ESFileStore.java:107) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.env.Environment.getFileStore(Environment.java:340) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.env.NodeEnvironment$NodePath.(NodeEnvironment.java:108) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.env.NodeEnvironment.(NodeEnvironment.java:227) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.node.Node.(Node.java:252) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.node.Node.(Node.java:232) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.bootstrap.Bootstrap$6.(Bootstrap.java:241) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:241) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) ~[elasticsearch-5.2.2.jar:5.2.2]  
... 6 more

What have I missed?

Br Mathias

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [April 7, 2017, 2:11pm UTC](https://discuss.elastic.co/t/cant-create-lock-file-when-sharing-data-path-folder-between-docker-and-host/81617/2 "2017-04-07T14:11:32Z")

</div>

Have a look at [https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-node.html#max-local-storage-nodes](https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-node.html#max-local-storage-nodes)

If you are doing this in production it probably is a good idea not to share data directories though.

---

<div class="post-metadata">

**Author:** ![mathias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mathias/32/23176_2.png) [@mathias](https://discuss.elastic.co/u/mathias)\
**Post date:** [April 7, 2017, 4:09pm UTC](https://discuss.elastic.co/t/cant-create-lock-file-when-sharing-data-path-folder-between-docker-and-host/81617/3 "2017-04-07T16:09:07Z")

</div>

Thanks for your reply Nik.

Unfortunately does not increasing node.max\_local\_storage\_nodes change anything.

I tried with 2 and 10 but no difference.

WARNING: Localhost DNS setting (--dns=127.0.0.1) may fail in containers.  
[2017-04-07T16:03:37,226][INFO][o.e.n.Node] [] initializing ...  
[2017-04-07T16:03:37,280][WARN][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]  
org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: failed to obtain node locks, tried [[/usr/share/elasticsearch/data/elasticsearch]] with lock ids [0--9]; maybe these locations are not writable or multiple nodes were started without increasing [node.max\_local\_storage\_nodes] (was [10])?  
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:125) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.cli.Command.main(Command.java:88) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:89) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:82) ~[elasticsearch-5.2.2.jar:5.2.2]  
Caused by: java.lang.IllegalStateException: failed to obtain node locks, tried [[/usr/share/elasticsearch/data/elasticsearch]] with lock ids [0--9]; maybe these locations are not writable or multiple nodes were started without increasing [node.max\_local\_storage\_nodes] (was [10])?  
at org.elasticsearch.env.NodeEnvironment.(NodeEnvironment.java:260) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.node.Node.(Node.java:252) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.node.Node.(Node.java:232) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.bootstrap.Bootstrap$6.(Bootstrap.java:241) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:241) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-5.2.2.jar:5.2.2]  
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121) ~[elasticsearch-5.2.2.jar:5.2.2]  
... 6 more  
Caused by: java.io.IOException: failed to obtain lock on /usr/share/elasticsearch/data/nodes/9

bash-4.3# ls -l /usr/share/elasticsearch/  
total 224  
-rw-r--r-- 1 elastics elastics 11358 Feb 24 17:24 LICENSE.txt  
-rw-r--r-- 1 elastics elastics 172700 Feb 24 17:24 NOTICE.txt  
-rw-r--r-- 1 elastics elastics 9108 Feb 24 17:24 README.textile  
drwxr-xr-x 1 elastics elastics 4096 Apr 7 16:03 bin  
drwxr-xr-x 1 elastics elastics 4096 Apr 7 16:03 config  
drwxr-xr-x 3 elastics elastics 4096 Apr 7 15:59 data  
drwxr-xr-x 1 elastics elastics 4096 Feb 24 17:29 lib  
drwxr-xr-x 1 elastics elastics 4096 Apr 7 11:50 logs  
drwxr-xr-x 1 elastics elastics 4096 Feb 24 17:29 modules  
drwxr-xr-x 1 elastics elastics 4096 Feb 24 17:29 plugins  
bash-4.3# ls -l /usr/share/elasticsearch/data  
total 4  
drwxr-xr-x 12 elastics elastics 4096 Apr 7 16:03 nodes  
bash-4.3# ls -l /usr/share/elasticsearch/data/nodes/  
total 40  
drwxr-xr-x 2 elastics elastics 4096 Apr 7 15:59 0  
drwxr-xr-x 2 elastics elastics 4096 Apr 7 16:01 1  
drwxr-xr-x 2 elastics elastics 4096 Apr 7 16:03 2  
drwxr-xr-x 2 elastics elastics 4096 Apr 7 16:03 3  
drwxr-xr-x 2 elastics elastics 4096 Apr 7 16:03 4  
drwxr-xr-x 2 elastics elastics 4096 Apr 7 16:03 5  
drwxr-xr-x 2 elastics elastics 4096 Apr 7 16:03 6  
drwxr-xr-x 2 elastics elastics 4096 Apr 7 16:03 7  
drwxr-xr-x 2 elastics elastics 4096 Apr 7 16:03 8  
drwxr-xr-x 2 elastics elastics 4096 Apr 7 16:03 9  
bash-4.3# ls -l /usr/share/elasticsearch/data/nodes/0/  
total 0  
-rw-r--r-- 1 elastics elastics 0 Apr 7 15:59 node.lock  
bash-4.3# ls -l /usr/share/elasticsearch/data/nodes/1/  
total 0  
-rw-r--r-- 1 elastics elastics 0 Apr 7 16:01 node.lock  
bash-4.3# ls -l /usr/share/elasticsearch/data/nodes/2/  
total 0  
-rw-r--r-- 1 elastics elastics 0 Apr 7 16:03 node.lock

Must be something else that is wrong.

I am running the docker in a vm and need access to a larger disk on a cinder volume which I can have from docker host. That is the reason why I need to share the data folder with docker host.

Br Mathias

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [April 7, 2017, 11:16pm UTC](https://discuss.elastic.co/t/cant-create-lock-file-when-sharing-data-path-folder-between-docker-and-host/81617/4 "2017-04-07T23:16:11Z")

</div>

> [@mathias](#):
>
> ```auto
> Caused by: java.io.IOException: Mount point not found
> atsun.nio.fs.LinuxFileStore.findMountEntry(LinuxFileStore.java:91) ~[?:?]
> 
> ```

This is the root of your problem. What storage driver are you using? Is it either of overlay or overlay2 by chance? Are you using a musl libc based image?

---

<div class="post-metadata">

**Author:** ![mathias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mathias/32/23176_2.png) [@mathias](https://discuss.elastic.co/u/mathias)\
**Post date:** [April 8, 2017, 5:29am UTC](https://discuss.elastic.co/t/cant-create-lock-file-when-sharing-data-path-folder-between-docker-and-host/81617/5 "2017-04-08T05:29:44Z")

</div>

Hi Json,

Here are some more background details:  
I used Alpine docker Elasticsearch v5.2.2 running on ubuntu16.04 (cloud image).  
Cinder volume is not connected to my cloud so I currently just want to store my data in home directory of ubuntu.

sblk -f  
NAME FSTYPE LABEL UUID MOUNTPOINT  
sr0 iso9660 config-2 2017-04-07-13-37-53-00  
vda  
└─vda1 ext4 cloudimg-rootfs b14f53da-7bc9-4604-a014-341f669f87c0 /

blkid  
/dev/vda1: LABEL="cloudimg-rootfs" UUID="b14f53da-7bc9-4604-a014-341f669f87c0" TYPE="ext4" PARTUUID="f1917857-01"  
/dev/sr0: UUID="2017-04-07-13-37-53-00" LABEL="config-2" TYPE="iso9660"

uname -a  
Linux docker-vm-0 4.4.0-47-generic #68-Ubuntu SMP Wed Oct 26 19:39:52 UTC 2016 x86\_64 x86\_64 x86\_64 GNU/Linux  
ubuntu@docker-vm-0:~/Dockers/elasticsearch2$ cat /etc/issue  
Ubuntu 16.04.1 LTS \n \l

I start my mongodb docker in the same way and I do not have any problem whatsoever whit in this case.

Br Mathias

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [April 8, 2017, 1:14pm UTC](https://discuss.elastic.co/t/cant-create-lock-file-when-sharing-data-path-folder-between-docker-and-host/81617/6 "2017-04-08T13:14:59Z")

</div>

Thanks, that confirms that you're using musl libc. Unless I'm overlooking something, I do not see enough information to conclude whether or not you are using either of overlay or overlay2. I strongly suspect that you are. In this case, I think that you are a victim of this [bug](https://bugs.alpinelinux.org/issues/7093). If you switch your storage driver away from overlay or overlay2 (say, aufs), or to an image based on glibc, you should be fine.

---

<div class="post-metadata">

**Author:** ![mathias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mathias/32/23176_2.png) [@mathias](https://discuss.elastic.co/u/mathias)\
**Post date:** [April 8, 2017, 3:06pm UTC](https://discuss.elastic.co/t/cant-create-lock-file-when-sharing-data-path-folder-between-docker-and-host/81617/7 "2017-04-08T15:06:41Z")

</div>

Thanks for that Jason,

Overlay2 seems to be what I am using.

sudo ls -l /var/lib/docker/  
total 64  
drwx------ 16 root root 4096 Apr 8 05:13 containers  
drwx------ 3 root root 4096 Apr 7 11:41 image  
drwxr-x--- 3 root root 4096 Apr 7 11:41 network  
drwx------ 269 root root 28672 Apr 8 05:13 overlay2  
drwx------ 4 root root 4096 Apr 7 11:41 plugins  
drwx------ 2 root root 4096 Apr 7 11:41 swarm  
drwx------ 2 root root 4096 Apr 8 05:03 tmp  
drwx------ 2 root root 4096 Apr 7 11:41 trust  
drwx------ 7 root root 4096 Apr 8 05:13 volumes  
ubuntu@docker-vm-0:~$ sudo ls -l /var/lib/docker/overlay2  
total 1088  
drwx------ 5 root root 4096 Apr 7 11:47 018b82cd15470d1ee0cba21290ec84c8f2c3d75985815d7d2a81499585f08cd5  
drwx------ 5 root root 4096 Apr 7 11:46 04c22cc4052327a70c4b95a16daff0fea0e3a14a5943bbf908a1643fb9e58e87  
drwx------ 5 root root 4096 Apr 7 19:13 05e8f3b217c83a32e3070e6b39ca66dd3360ff77d6fe121d032a387ee09ae351

I will monitor the bug and hope for a quick fix.

Thanks  
Mathias

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [April 8, 2017, 5:48pm UTC](https://discuss.elastic.co/t/cant-create-lock-file-when-sharing-data-path-folder-between-docker-and-host/81617/8 "2017-04-08T17:48:24Z")

</div>

You're welcome.

---

<div class="post-metadata">

**Author:** ![mathias](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mathias/32/23176_2.png) [@mathias](https://discuss.elastic.co/u/mathias)\
**Post date:** [April 9, 2017, 10:50am UTC](https://discuss.elastic.co/t/cant-create-lock-file-when-sharing-data-path-folder-between-docker-and-host/81617/9 "2017-04-09T10:50:33Z")

</div>

Hi,

I can also confirm that the debian based image works well.

Br Mathias

---

<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:** [May 7, 2017, 10:51am UTC](https://discuss.elastic.co/t/cant-create-lock-file-when-sharing-data-path-folder-between-docker-and-host/81617/10 "2017-05-07T10:51:31Z")

</div>

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