Docker mounts files as uid 1001 I have a Docker image that runs a PHP application. Everything works fine on my machine and the ones of my colleagues.
However, some colleagues got a new computer that runs on Ubuntu 20.04 and by default the user on these computers have the user id 1001. If I run the id command on these computers I get 1001 for the user id and group id. So, when they starts the container, the files are chown with 1001:1001 and the code cannot be executed and no files can be written in the document root of the project.
Do you know what is happening ?
Thanks for your answers!
Ideally dont run docker as superuser(root). You should create a user within dockerfile and chown the file system with that user. You can create a user and then add access to that user on the file system. In the below example there is appuser , with ownership to src
FROM ubuntu:latest
RUN useradd -r -u 1001 -g appuser appuser
RUN chown -R appuser.appuser /src
USER appuser
CMD [&quot;appuser&quot;, &quot;/src/index.js&quot;] 

Its not recommended to run as root
You could also run as any user (Say root id = 0) if needed from externally
docker run -d --user 0 ubuntu:latest

You should never relay on gid/uid  of the linux user outside the container.