Docker set custom PUID, PGID

Hello.

The current n8n docker installation runs with PUID and PGID of 1000.

By doing this n8n runs on the system with the user 1000 is assigned.

For example in my installation environment 1000 id is the user mysql.

So n8n runs as mysql user.

The problem is when you create a folder or a volume and map this to docker and wants the n8n to write, edit and delete files and folders inside this parent folder, you have to chown the permissions for the parent folder to that of mysql user in my example.

The best thing is to create a user in linux for the n8n installation and assign that ID to the docker via environent variables.

So in docker compose will look something like that:

environment:

  • PUID=1002
  • PGID=1002

Please consider adding that option so we stop using others users permissions to folders and files so that n8n can write and modify files and folders locally in host.

Example of similar problem here:

Thanks so much for raising this @Mulen! Don’t forget to vote on your feature request :slight_smile:

1 Like

It would be excellent to support this for sharing application data across NFS volumes. My specific use-case is that I have n8n deployed in a small k3s cluster and have set custom filesystem permissions for certain deployments and namespaces.

Most, if not all linuxserver.io containers implement this handy feature which makes deployment a lot more flexible!

This is such a basic feature that a lot of projects support. Really love to see it in n8n as well!

is there any progress on this? i’m struggling with a docker install on Synology, specifically to mount and map a persistent volume to /home/node/.n8n, and the problem is entirely because i can’t set a custom PUID and PGID on the container.

hi @wheeleran did you find out how to do it ? I’m exactly in the same predicament.

Yes I did. In docker-compose your mapped volumes need ‘:rw’ at the end, so ‘/n8n:rw’ and ‘/files:rw’ and so on, and permissions need to be explicit. The Marius guide goes through this in points 13-16 and it’s correct, because n8n installs and tries to write as 1000:1000 and I’ve not yet found a docker-compose that can set custom PUID and GUIDs. Right click the n8n docker folder, then Permissions > Advanced options. Select ‘make inherited permissions explicit’,
then in User or Group list, select Everyone, click Edit
, then tick the box next to Write, then Done and save.

I custom a Dockerfile to solved this problem, replace uid to your host uid

FROM n8nio/n8n

USER root

RUN deluser node || true

RUN adduser -D -u 1026 -G users node

RUN mkdir -p /home/node && chown -R node:users /home/node

USER node

1 Like

created an account just to say thank you!

solved my problem where my cloud computing service has injected themselves as the default user 1000 with my user as 1001. i couldn’t stand combing my docker volumes and seeing my files not being owned by me!