Docker Permissions – Fixing ‘Operation Not Permitted’ Error for chmod

containersdockerfile-permissions

While running the following docker file I am getting "chmod: changing permissions of '/scripts/entrypoint.sh': Operation not permitted" error.

FROM sonarqube:7.7-community
ADD plugins/* /plugins/
ADD scripts/* /scripts/
ADD conf/* /conf/
ADD bin/* /bin/
RUN chmod -R a+X /scripts/myScript.sh
ENTRYPOINT ["/scripts/myScript.sh"]

But when I add USER root it is working. But I don't want to run it with root.
Any way I can run it without root ?

Best Answer

Set the permissions before you build the image

chmod +x scripts/myScript.sh
docker build .

docker will keep the permissions when it copies the files.