'start a postgis docker container with custom user

I am using "postgis/postgis:11-3.0" image and in terms of security i would like to autolog as a none root privileged user(not root or postgres user). In order to get that this is

my Dockerfile:

FROM postgis/postgis:11-3.0

#USER & GROUP

RUN groupadd my-group\
    && useradd -m my-user -g my-group

RUN chown -R my-user:my-group /var/lib/postgresql/data/
RUN chmod 777 /var/lib/postgresql/data/


USER my-user

but my container shows the next error chmod: changing permissions of '/var/lib/postgresql/data': Operation not permitted

what can i do?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source