Dockerized node.js and bind mount permission problem I have an interesting problem with node, docker-compose and local development using bind mounts.
I have a bind mount volume, called www-public, owned by my host node user (I created a node user and chowned the dir to node:node). The container (official node) is set up so it also run as node user. At some point in my node app, i need to write to this folder and i get the permission error. This seems strange at first, but it makes sense, because i figured then, that my host nodeuser has an uid of 1001 while my container node user has an id of 1000. If i just add this line to my Dockerfile:
RUN usermod -u 1001 node &amp;&amp; groupmod -g 1001 node

The permission problem goes away.
How do i fix this in a way, that I don't hard code the container node user id to match the node user id on the host like i did with the upper RUN command.
In your Dockerfile:
ARG UID=1000
ARG GID=1000

RUN usermod -u $UID node &amp;&amp; groupmod -g $GID node

Then using docker build:
docker build --build-arg UID=$(id -u) --build-arg GID=$(id -g) .

The ARG lines provide defaults. If you leave off the --build-arg flags, they will be used. If you do use the --build-arg flags values those will be used instead.