Any way to change uid of elasticsearch user in docker image?

Hi all,

Is there any way to change the uid of the elasticsearch user in the oss elasticsearch docker image without rebuilding the image ?

I'm using docker.elastic.co/elasticsearch/elasticsearch-oss:6.1.2, and I can see that elasticsearch has a uid of 1000. This is a reserved uid in my environment, so I need to change this to 1001.

Ideally I want to keep using upstream without owning the maintenance of the image, but just change this. Is there any simple way to do this ?

Thanks,

Looks like the solution is to build a new image FROM the upstream ...
Dockerfile

ARG VERSION=6.1.2
FROM docker.elastic.co/elasticsearch/elasticsearch-oss:$VERSION 
RUN groupmod -g 1001 elasticsearch
RUN usermod -u 1001 -g 1001 elasticsearch
RUN chown -R elasticsearch /usr/share/elasticsearch
RUN sed -i -e 's/--userspec=1000/--userspec=1001/g' \
           -e 's/UID 1000/UID 1001/' \
           -e 's/chown -R 1000/chown -R 1001/' /usr/local/bin/docker-entrypoint.sh
RUN chown elasticsearch /usr/local/bin/docker-entrypoint.sh

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