Skip to content

Cannot change the permission of data folder when using boot2docker. #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
k1xme opened this issue May 14, 2015 · 5 comments · Fixed by #77
Closed

Cannot change the permission of data folder when using boot2docker. #27

k1xme opened this issue May 14, 2015 · 5 comments · Fixed by #77

Comments

@k1xme
Copy link

k1xme commented May 14, 2015

In docker_entrypoint.sh, this image will exec chown -R elasticsearch:elasticsearch /usr/share/elasticsearch/data to change the ownership of the mounted data folder.

But when I use boot2docker to run this image, I got an error as following:

[2015-05-14 22:02:10,344][INFO ][node ] [Her] version[1.5.2], pid[40], build[62ff986/2015-04-27T09:21:06Z]
[2015-05-14 22:02:10,345][INFO ][node ] [Her] initializing ...
[2015-05-14 22:02:10,356][INFO ][plugins ] [Her] loaded [marvel], sites [marvel]
{1.5.2}: Initialization Failed ...

  • ElasticsearchIllegalStateException[Failed to created node environment]
    AccessDeniedException[/usr/share/elasticsearch/data/elasticsearch]

This is because boot2docker uses vboxfs to share the files between Host Mac and the VM that actually runs docker, and VM cannot change the permission or ownership of the folders on Host Mac.

One workaround is to create the data folder inside the VM, and mount that folder on the container.

I guess using data container might also works, but haven't tried it, and even if it works, it might still have some performance issues.

@k1xme
Copy link
Author

k1xme commented May 14, 2015

this issue is duplicate to #5 .

@kadishmal
Copy link

I am having a similar issue:

$ docker run elasticsearch:1.4.5 elasticsearch
[2015-10-30 06:01:06,939][INFO ][node                     ] [Molten Man] version[1.4.5], pid[1], build[2aaf797/2015-04-27T08:06:06Z]
[2015-10-30 06:01:06,940][INFO ][node                     ] [Molten Man] initializing ...
[2015-10-30 06:01:06,947][INFO ][plugins                  ] [Molten Man] loaded [], sites []
{1.4.5}: Initialization Failed ...
- ElasticsearchIllegalStateException[Failed to obtain node lock, is the following location writable?: [/usr/share/elasticsearch/data/elasticsearch]]
    IOException[failed to obtain lock on /usr/share/elasticsearch/data/elasticsearch/nodes/49]
        IOException[Cannot create directory: /usr/share/elasticsearch/data/elasticsearch/nodes/49]
naverui-MacBook-Pro-6:elasticsearch-docker naver$ docker run --rm elasticsearch:1.4.5 id elasticsearch
uid=105(elasticsearch) gid=108(elasticsearch) groups=108(elasticsearch)

Using Docker Toolbox with the default VirtualBox machine. Can't start even with default configurations despite not using the volume mounts.

If it's duplicate of #5, then what is the solution? The README says to run docker run -d elasticsearch which doesn't work out of the box.

@Garito
Copy link

Garito commented Nov 26, 2015

This is a recursive duplication error right now (not the elasticsearch error but the issue citation)
We can't find a good solution anywhere

@david-mohr
Copy link

Here's my workaround for OSX using Docker Toolbox: Change the UID of the elasticsearch container user to match the docker UID of the VirtualBox machine and then use a quick script to sure up the permissions in the container to use the new UID. You could build your own image to implement this or you could use the following scripts and docker command to use the default elasticsearch image:

fix-perm-osx.sh

OLD_ES_UID=$(id -u elasticsearch)
echo "OLD elasticsearch UID: ${OLD_ES_UID}"
usermod -u ${OSX_DOCKER_UID} elasticsearch
echo "NEW elasticsearch UID: $(id -u elasticsearch)"
find / -uid ${OLD_ES_UID} -exec chown elasticsearch {} \; 2>/dev/null
exec /docker-entrypoint.sh "$@"

Then execute the container and you should be able to successfully mount the data directory:

docker run -d -e "OSX_DOCKER_UID=$(docker-machine ssh default id -u)" -v "$PWD/fix-perm-osx.sh":/fix-perm-osx.sh -v "$PWD/data":/usr/share/elasticsearch/data elasticsearch /fix-perm-osx.sh elasticsearch

@akobler
Copy link

akobler commented Jan 6, 2016

@david-mohr great, that works for me. One little adaption: I had to single-quote the 'id -u' as below.

docker run -d -e "OSX_DOCKER_UID=$(docker-machine ssh default 'id -u')  -v "$PWD/fix-perm-osx.sh":/fix-perm-osx.sh -v "$PWD/data":/usr/share/elasticsearch/data elasticsearch /fix-perm-osx.sh elasticsearch" 

1gtm pushed a commit to appscode-images/elasticsearch that referenced this issue Feb 14, 2024
* Add Logstash to readme

Add a Logstash section to the readme following the format of Kibana and
Elasticsearch.

* Remove open source mention
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants