makuk66 / docker-solr

Solr on Docker
86 stars 40 forks source link

set gid and uid to 1000 for solr user to be able to use a volume for sol... #4

Closed cornelius-keller closed 9 years ago

cornelius-keller commented 9 years ago

...rhome

Hi Martijn,

I am a DevOps and have no deep knowledge of solr, but for our usecase I needed to have the solrhome in a shared volume. Because there are permission issues with the container as it was I changed the gid and uid of the solr user to 1000. Now it is working for me and I thought it might be useful for others.

makuk66 commented 9 years ago

Cornelius: I'm glad you got your configuration working.

The reason your patch worked for you is that your uid+guid in the docker host apparently was 1000 (presumably because you were the first user), and you changed your container solr user to match it. The same value would not necessarily work for other people who may have different uids. Or it might work for a 1000 user in an environment where that is not desired. So I'm a little hesitant to start changing default to specific numbers.

The Dockerfile uses groupadd -g and useradd -g, which creates system groups. This follows the example of the official "postgres", "mysql", "redis" images. System users end up being 999 per the /etc/adduser.conf. If we created a normal user, then it would get 1000, and it would happen to work for you; so rather than specifying -g 1000 and -u 1000 you should be able to just remove the -g. But, that would have other implications too (there would be a /home/solr etc).

Given all this, I'm inclined not to make a change at this time, but I'll keep an eye out for discussions of this aspect in the wider Docker community. I may well become convinced that this would be a worthwhile usability feature.

By the way, I'm not sure if it is applicable to your use-case, but have a look at this discussion and this blog post which discusses an alternative approach to volume management.

Thank you for taking the time to document this; it may well be useful to others.

cornelius-keller commented 9 years ago

Hi Martijn,

thank you for clarifying the gui/uid thing to me. Indeed I have uid/gid 1000 on the host system. The funny thing is that a lot of other containers I have seen so far seem to rely on this fact, like for example the official jenkins images. For now this is workning for me but you are right that I have to look deeper into the data container stuff.

Thanks for your time