How to change userid in docker contianer for bind mounting config / data?

Hi,

the container for logstash, elasticsearch and kibana are using user:group 1000:1000 inside of the container.

If I would like to use bind mounts to link in custom configuration or the data folder, I need to give user 1000:1000 read (for config) and write (for data) permissions on the host to these folders.

What is best practice if userid 1000 is already in use? I don't want to need give the user who is already using the id on the host a new id. In centos for example the first user who is created gets userid 1000 by default. So taking id 1000 for elasticsearch may collide quite often.

So what's best practice?

  1. change userid in docker container to the one matching which is used for user elasticsearch on the host?
  2. use volumes?
    2.1. I assume volumes are slower than bind mounts. Can one neglect the speed difference? What is the common difference in percent?
  3. Any other approach

Thanks, Andreas

1 Like

my solution for now is modifying elastic's docker image. I am changing user and group IDs to my needs and changing the ownership of the files to fit to the new IDs. Id's are defined as build-arg.

So I just followed the steps here:

Maybe it helps someone :wink:

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