[GH-ISSUE #1226] Add UID and GID variable #997

Closed
opened 2026-02-26 06:35:22 +03:00 by kerem · 15 comments
Owner

Originally created by @mgutt on GitHub (Jul 9, 2021).
Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/1226

In Unraid its important of being able to set UID and GID to 99:100. I tried it through the following docker flag:

--user=99:100

But the NPM docker container isn't happy with it:

s6-mkdir: warning: unable to mkdir /var/run/s6: Permission denied

Some containers solve this by using additional variables:
https://hub.docker.com/r/linuxserver/mariadb#:~:text=boot%20and%20setup.-,Usage,-Here%20are%20some

    environment:
      - PUID=1000
      - PGID=1000
Originally created by @mgutt on GitHub (Jul 9, 2021). Original GitHub issue: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/1226 In Unraid its important of being able to set UID and GID to 99:100. I tried it through the following docker flag: ``` --user=99:100 ``` But the NPM docker container isn't happy with it: ``` s6-mkdir: warning: unable to mkdir /var/run/s6: Permission denied ``` Some containers solve this by using additional variables: https://hub.docker.com/r/linuxserver/mariadb#:~:text=boot%20and%20setup.-,Usage,-Here%20are%20some ``` environment: - PUID=1000 - PGID=1000 ```
kerem 2026-02-26 06:35:22 +03:00
Author
Owner

@joshkay commented on GitHub (Jul 19, 2022):

@mgutt did you ever find a workaround for this?

<!-- gh-comment-id:1189160000 --> @joshkay commented on GitHub (Jul 19, 2022): @mgutt did you ever find a workaround for this?
Author
Owner

@mgutt commented on GitHub (Jul 19, 2022):

Nope.

<!-- gh-comment-id:1189180137 --> @mgutt commented on GitHub (Jul 19, 2022): Nope.
Author
Owner

@rogierlommers commented on GitHub (Dec 24, 2022):

I would love to have this working indeed.
Also see my bug report: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/2503

<!-- gh-comment-id:1364543042 --> @rogierlommers commented on GitHub (Dec 24, 2022): I would love to have this working indeed. Also see my bug report: https://github.com/NginxProxyManager/nginx-proxy-manager/issues/2503
Author
Owner

@rogierlommers commented on GitHub (Dec 24, 2022):

Please also see this: https://github.com/jlesage/docker-nginx-proxy-manager/issues/271
I don't know what repo that is, but it does support docker --user params.
Personally I prefer to use this (original) one, but I do need to save data files as my own user.

<!-- gh-comment-id:1364543397 --> @rogierlommers commented on GitHub (Dec 24, 2022): Please also see this: https://github.com/jlesage/docker-nginx-proxy-manager/issues/271 I don't know what repo that is, but it does support docker --user params. Personally I prefer to use this (original) one, but I do need to save data files as my own user.
Author
Owner

@ghost commented on GitHub (Jan 24, 2023):

There is a s6-applyuidgid directive to do this after init. The jslesage repo seems to be quite a bit behind, also would not recommend using another source for your reverse proxy.

Writing everything as root on the host can interfere with common backup strategies, RAID setups and remote monitoring. Would love to see this get picked up soon.

<!-- gh-comment-id:1401621682 --> @ghost commented on GitHub (Jan 24, 2023): There is a `s6-applyuidgid` directive to do this after init. The `jslesage` repo seems to be quite a bit behind, also would not recommend using another source for your reverse proxy. Writing everything as root on the host can interfere with common backup strategies, RAID setups and remote monitoring. Would love to see this get picked up soon.
Author
Owner

@rogierlommers commented on GitHub (Jan 24, 2023):

Yes me too; I don't want to use the jslesage repo either. So for me it's a must-have. Unfortunately I don't have the time nor skills to apply it in this repo 🙁.

<!-- gh-comment-id:1402232989 --> @rogierlommers commented on GitHub (Jan 24, 2023): Yes me too; I don't want to use the jslesage repo either. So for me it's a must-have. Unfortunately I don't have the time nor skills to apply it in this repo 🙁.
Author
Owner

@agorgl commented on GitHub (Feb 2, 2023):

Waiting for this too!

<!-- gh-comment-id:1414227156 --> @agorgl commented on GitHub (Feb 2, 2023): Waiting for this too!
Author
Owner

@vdrover commented on GitHub (Apr 21, 2023):

This is working for me: https://hub.docker.com/r/jc21/nginx-proxy-manager

    environment:
      PUID: $PUID
      PGID: $PGID

192 168 86 59 2023-04-20 at 11 01 45 PM

<!-- gh-comment-id:1517227621 --> @vdrover commented on GitHub (Apr 21, 2023): This is working for me: https://hub.docker.com/r/jc21/nginx-proxy-manager ``` environment: PUID: $PUID PGID: $PGID ``` ![192 168 86 59 2023-04-20 at 11 01 45 PM](https://user-images.githubusercontent.com/3143313/233538302-1846fd12-f6b1-4906-a8e0-90c3d3ba76e4.jpg)
Author
Owner

@Moooartin commented on GitHub (Sep 18, 2023):

Sorry to re-open this thread but the issue has changed a bit...
Since the environment have been added, The PUID and PGID work fine for the 2.10.2 and 2.10.3 but it is not working with the latest 2.10.4.

Has it been removed?

<!-- gh-comment-id:1723115679 --> @Moooartin commented on GitHub (Sep 18, 2023): Sorry to re-open this thread but the issue has changed a bit... Since the environment have been added, The `PUID` and `PGID` work fine for the `2.10.2` and `2.10.3` but it is not working with the latest `2.10.4`. Has it been removed?
Author
Owner

@NeoMod commented on GitHub (Oct 31, 2023):

thank you @vdrover. I can confirm this is working fine on latest and solved the bunch of errors about file permission at startup under unraid.

<!-- gh-comment-id:1786942167 --> @NeoMod commented on GitHub (Oct 31, 2023): thank you @vdrover. I can confirm this is working fine on _latest_ and solved the bunch of errors about file permission at startup under unraid.
Author
Owner

@malavolti commented on GitHub (Dec 14, 2024):

Dear @jc21, @vdrover ,

I want to run NPM with Docker and its Rootless mode.

# id marco
# uid=1000(marco) gid=1000(marco) ... groups=1000(marco), ..., 996(docker)

This is my docker-compose.yml:

services:
  nginx-proxy-manager:
    image: 'jc21/nginx-proxy-manager:2.12.1'
    container_name: nginx-proxy-manager
    environment:
      PUID: 1000
      PGID: 1000
      TZ: Europe/Rome
    restart: unless-stopped
    ports:
      - 80:80
      - 81:81
      - 443:443
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt

and I get:

-------------------------------------
 _   _ ____  __  __
| \ | |  _ \|  \/  |
|  \| | |_) | |\/| |
| |\  |  __/| |  | |
|_| \_|_|   |_|  |_|
-------------------------------------
User:  npm PUID:1000 ID:1000 GROUP:1000
Group: npm PGID:1000 ID:1000
-------------------------------------

❯ Starting nginx ...
❯ Starting backend ...
nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:4
[12/14/2024] [11:24:06 PM] [Global   ] › ℹ  info      Using Sqlite: /data/database.sqlite
[12/14/2024] [11:24:06 PM] [Global   ] › ℹ  info      Creating a new JWT key pair...
...

But folders get different UID and GID:

drwxr-xr-x 7 100999 100999 4096 14 dic 23.24 data
drwxr-xr-x 2 100999 100999 4096 14 dic 23.21 letsencrypt

can you tell me why, please?

Thank you so much!
Marco

<!-- gh-comment-id:2543363259 --> @malavolti commented on GitHub (Dec 14, 2024): Dear @jc21, @vdrover , I want to run NPM with Docker and its Rootless mode. ``` # id marco # uid=1000(marco) gid=1000(marco) ... groups=1000(marco), ..., 996(docker) ``` This is my `docker-compose.yml`: ```bash services: nginx-proxy-manager: image: 'jc21/nginx-proxy-manager:2.12.1' container_name: nginx-proxy-manager environment: PUID: 1000 PGID: 1000 TZ: Europe/Rome restart: unless-stopped ports: - 80:80 - 81:81 - 443:443 volumes: - ./data:/data - ./letsencrypt:/etc/letsencrypt ``` and I get: ```bash ------------------------------------- _ _ ____ __ __ | \ | | _ \| \/ | | \| | |_) | |\/| | | |\ | __/| | | | |_| \_|_| |_| |_| ------------------------------------- User: npm PUID:1000 ID:1000 GROUP:1000 Group: npm PGID:1000 ID:1000 ------------------------------------- ❯ Starting nginx ... ❯ Starting backend ... nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:4 [12/14/2024] [11:24:06 PM] [Global ] › ℹ info Using Sqlite: /data/database.sqlite [12/14/2024] [11:24:06 PM] [Global ] › ℹ info Creating a new JWT key pair... ... ``` But folders get different UID and GID: ```bash drwxr-xr-x 7 100999 100999 4096 14 dic 23.24 data drwxr-xr-x 2 100999 100999 4096 14 dic 23.21 letsencrypt ``` can you tell me why, please? Thank you so much! Marco
Author
Owner

@vdrover commented on GitHub (Dec 15, 2024):

Just a bit of a stab in the dark, but have you added your user to the docker group?

https://docs.docker.com/engine/install/linux-postinstall/

<!-- gh-comment-id:2543407571 --> @vdrover commented on GitHub (Dec 15, 2024): Just a bit of a stab in the dark, but have you added your user to the docker group? https://docs.docker.com/engine/install/linux-postinstall/
Author
Owner

@malavolti commented on GitHub (Dec 15, 2024):

Just a bit of a stab in the dark, but have you added your user to the docker group?

https://docs.docker.com/engine/install/linux-postinstall/

Yes, I've added.

<!-- gh-comment-id:2544071555 --> @malavolti commented on GitHub (Dec 15, 2024): > Just a bit of a stab in the dark, but have you added your user to the docker group? > > https://docs.docker.com/engine/install/linux-postinstall/ Yes, I've added.
Author
Owner

@malavolti commented on GitHub (Dec 22, 2024):

https://github.com/NginxProxyManager/nginx-proxy-manager/issues/3252

I report also this issue that is rely on my problem.

Any help about this @vdrover @jc21 ? Thank you so much!

<!-- gh-comment-id:2558588072 --> @malavolti commented on GitHub (Dec 22, 2024): https://github.com/NginxProxyManager/nginx-proxy-manager/issues/3252 I report also this issue that is rely on my problem. Any help about this @vdrover @jc21 ? Thank you so much!
Author
Owner

@ashipaek0 commented on GitHub (Dec 28, 2024):

Seems this issue where it does not respect the PGUID set and changes the folder ownership on boot is causing SSL acquisition to fail

before starting container

drwxr-xr-x 4 ashipa ashipa 4096 Dec 28 11:25 .
drwxr-xr-x 4 ashipa ashipa 4096 Dec 27 15:55 ..
drwxrwxrwx 7 ashipa ashipa 4096 Dec 28 11:24 data
-rwxr-xr-x 1 ashipa ashipa  335 Dec 28 11:25 docker-compose.yml
drwxrwxrwx 5 ashipa ashipa 4096 Dec 28 11:19 letsencrypt

after starting container

drwxr-xr-x 4 ashipa ashipa 4096 Dec 28 11:25 .
drwxr-xr-x 4 ashipa ashipa 4096 Dec 27 15:55 ..
drwxrwxrwx 7 100999 100999 4096 Dec 28 11:24 data
-rwxr-xr-x 1 ashipa ashipa  335 Dec 28 11:25 docker-compose.yml
drwxrwxrwx 5 100999 100999 4096 Dec 28 11:19 letsencrypt
app-1  | -------------------------------------
app-1  |  _   _ ____  __  __
app-1  | | \ | |  _ \|  \/  |
app-1  | |  \| | |_) | |\/| |
app-1  | | |\  |  __/| |  | |
app-1  | |_| \_|_|   |_|  |_|
app-1  | -------------------------------------
app-1  | User:  npm PUID:1000 ID:1000 GROUP:1000
app-1  | Group: npm PGID:1000 ID:1000
app-1  | -------------------------------------
app-1  | 
app-1  | ❯ Starting nginx ...
app-1  | ❯ Starting backend ...
app-1  | nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:4
app-1  | [12/28/2024] [11:30:36 AM] [Global   ] › ℹ  info      Using Sqlite: /data/database.sqlite
app-1  | [12/28/2024] [11:30:37 AM] [Migrate  ] › ℹ  info      Current database version: none
app-1  | [12/28/2024] [11:30:37 AM] [Setup    ] › ℹ  info      Logrotate Timer initialized
app-1  | [12/28/2024] [11:30:37 AM] [Setup    ] › ℹ  info      Logrotate completed.
app-1  | [12/28/2024] [11:30:37 AM] [IP Ranges] › ℹ  info      Fetching IP Ranges from online services...
app-1  | [12/28/2024] [11:30:37 AM] [IP Ranges] › ℹ  info      Fetching https://ip-ranges.amazonaws.com/ip-ranges.json
app-1  | [12/28/2024] [11:30:38 AM] [IP Ranges] › ℹ  info      Fetching https://www.cloudflare.com/ips-v4
app-1  | [12/28/2024] [11:30:38 AM] [IP Ranges] › ℹ  info      Fetching https://www.cloudflare.com/ips-v6
app-1  | [12/28/2024] [11:30:38 AM] [SSL      ] › ℹ  info      Let's Encrypt Renewal Timer initialized
app-1  | [12/28/2024] [11:30:38 AM] [SSL      ] › ℹ  info      Renewing SSL certs close to expiry...
app-1  | [12/28/2024] [11:30:38 AM] [IP Ranges] › ℹ  info      IP Ranges Renewal Timer initialized
app-1  | [12/28/2024] [11:30:38 AM] [Global   ] › ℹ  info      Backend PID 162 listening on port 3000 ...
app-1  | [12/28/2024] [11:30:39 AM] [Nginx    ] › ℹ  info      Reloading Nginx
app-1  | [12/28/2024] [11:30:39 AM] [SSL      ] › ℹ  info      Renew Complete
app-1  | Duplicate relation "access_list" in a relation expression. You should use "a.[b, c]" instead of "[a.b, a.c]". This will cause an error in objection 2.0
app-1  | [12/28/2024] [11:31:22 AM] [Nginx    ] › ⬤  debug     Deleting file: /data/nginx/proxy_host/4.conf
app-1  | [12/28/2024] [11:31:22 AM] [Nginx    ] › ⬤  debug     Deleting file: /data/nginx/proxy_host/4.conf.err
app-1  | [12/28/2024] [11:31:22 AM] [Nginx    ] › ⬤  debug     Could not delete file: {
app-1  |   "errno": -2,
app-1  |   "syscall": "unlink",
app-1  |   "code": "ENOENT",
app-1  |   "path": "/data/nginx/proxy_host/4.conf.err"
app-1  | }
app-1  | [12/28/2024] [11:31:22 AM] [Nginx    ] › ℹ  info      Reloading Nginx
app-1  | [12/28/2024] [11:31:27 AM] [SSL      ] › ℹ  info      Requesting Let'sEncrypt certificates for Cert #17: stream.ashipaek0.website
app-1  | [12/28/2024] [11:31:27 AM] [SSL      ] › ℹ  info      Command: certbot certonly --config "/etc/letsencrypt.ini" --work-dir "/tmp/letsencrypt-lib" --logs-dir "/tmp/letsencrypt-log" --cert-name "npm-17" --agree-tos --authenticator webroot --email "myemail@gmail.com" --preferred-challenges "dns,http" --domains "mydomain.com" 
app-1  | [12/28/2024] [11:31:39 AM] [Nginx    ] › ⬤  debug     Deleting file: /data/nginx/temp/letsencrypt_17.conf
app-1  | [12/28/2024] [11:31:39 AM] [Nginx    ] › ℹ  info      Reloading Nginx
app-1  | [12/28/2024] [11:31:39 AM] [Express  ] › ⚠  warning   Command failed: certbot certonly --config "/etc/letsencrypt.ini" --work-dir "/tmp/letsencrypt-lib" --logs-dir "/tmp/letsencrypt-log" --cert-name "npm-17" --agree-tos --authenticator webroot --email "myemail@gmail.com" --preferred-challenges "dns,http" --domains "mydomain.com" 
app-1  | Saving debug log to /tmp/letsencrypt-log/letsencrypt.log
app-1  | Some challenges have failed.
app-1  | Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /tmp/letsencrypt-log/letsencrypt.log or re-run Certbot with -v for more details.

<!-- gh-comment-id:2564298491 --> @ashipaek0 commented on GitHub (Dec 28, 2024): Seems this issue where it does not respect the PGUID set and changes the folder ownership on boot is causing SSL acquisition to fail before starting container ``` drwxr-xr-x 4 ashipa ashipa 4096 Dec 28 11:25 . drwxr-xr-x 4 ashipa ashipa 4096 Dec 27 15:55 .. drwxrwxrwx 7 ashipa ashipa 4096 Dec 28 11:24 data -rwxr-xr-x 1 ashipa ashipa 335 Dec 28 11:25 docker-compose.yml drwxrwxrwx 5 ashipa ashipa 4096 Dec 28 11:19 letsencrypt ``` after starting container ``` drwxr-xr-x 4 ashipa ashipa 4096 Dec 28 11:25 . drwxr-xr-x 4 ashipa ashipa 4096 Dec 27 15:55 .. drwxrwxrwx 7 100999 100999 4096 Dec 28 11:24 data -rwxr-xr-x 1 ashipa ashipa 335 Dec 28 11:25 docker-compose.yml drwxrwxrwx 5 100999 100999 4096 Dec 28 11:19 letsencrypt ``` ``` app-1 | ------------------------------------- app-1 | _ _ ____ __ __ app-1 | | \ | | _ \| \/ | app-1 | | \| | |_) | |\/| | app-1 | | |\ | __/| | | | app-1 | |_| \_|_| |_| |_| app-1 | ------------------------------------- app-1 | User: npm PUID:1000 ID:1000 GROUP:1000 app-1 | Group: npm PGID:1000 ID:1000 app-1 | ------------------------------------- app-1 | app-1 | ❯ Starting nginx ... app-1 | ❯ Starting backend ... app-1 | nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:4 app-1 | [12/28/2024] [11:30:36 AM] [Global ] › ℹ info Using Sqlite: /data/database.sqlite app-1 | [12/28/2024] [11:30:37 AM] [Migrate ] › ℹ info Current database version: none app-1 | [12/28/2024] [11:30:37 AM] [Setup ] › ℹ info Logrotate Timer initialized app-1 | [12/28/2024] [11:30:37 AM] [Setup ] › ℹ info Logrotate completed. app-1 | [12/28/2024] [11:30:37 AM] [IP Ranges] › ℹ info Fetching IP Ranges from online services... app-1 | [12/28/2024] [11:30:37 AM] [IP Ranges] › ℹ info Fetching https://ip-ranges.amazonaws.com/ip-ranges.json app-1 | [12/28/2024] [11:30:38 AM] [IP Ranges] › ℹ info Fetching https://www.cloudflare.com/ips-v4 app-1 | [12/28/2024] [11:30:38 AM] [IP Ranges] › ℹ info Fetching https://www.cloudflare.com/ips-v6 app-1 | [12/28/2024] [11:30:38 AM] [SSL ] › ℹ info Let's Encrypt Renewal Timer initialized app-1 | [12/28/2024] [11:30:38 AM] [SSL ] › ℹ info Renewing SSL certs close to expiry... app-1 | [12/28/2024] [11:30:38 AM] [IP Ranges] › ℹ info IP Ranges Renewal Timer initialized app-1 | [12/28/2024] [11:30:38 AM] [Global ] › ℹ info Backend PID 162 listening on port 3000 ... app-1 | [12/28/2024] [11:30:39 AM] [Nginx ] › ℹ info Reloading Nginx app-1 | [12/28/2024] [11:30:39 AM] [SSL ] › ℹ info Renew Complete app-1 | Duplicate relation "access_list" in a relation expression. You should use "a.[b, c]" instead of "[a.b, a.c]". This will cause an error in objection 2.0 app-1 | [12/28/2024] [11:31:22 AM] [Nginx ] › ⬤ debug Deleting file: /data/nginx/proxy_host/4.conf app-1 | [12/28/2024] [11:31:22 AM] [Nginx ] › ⬤ debug Deleting file: /data/nginx/proxy_host/4.conf.err app-1 | [12/28/2024] [11:31:22 AM] [Nginx ] › ⬤ debug Could not delete file: { app-1 | "errno": -2, app-1 | "syscall": "unlink", app-1 | "code": "ENOENT", app-1 | "path": "/data/nginx/proxy_host/4.conf.err" app-1 | } app-1 | [12/28/2024] [11:31:22 AM] [Nginx ] › ℹ info Reloading Nginx app-1 | [12/28/2024] [11:31:27 AM] [SSL ] › ℹ info Requesting Let'sEncrypt certificates for Cert #17: stream.ashipaek0.website app-1 | [12/28/2024] [11:31:27 AM] [SSL ] › ℹ info Command: certbot certonly --config "/etc/letsencrypt.ini" --work-dir "/tmp/letsencrypt-lib" --logs-dir "/tmp/letsencrypt-log" --cert-name "npm-17" --agree-tos --authenticator webroot --email "myemail@gmail.com" --preferred-challenges "dns,http" --domains "mydomain.com" app-1 | [12/28/2024] [11:31:39 AM] [Nginx ] › ⬤ debug Deleting file: /data/nginx/temp/letsencrypt_17.conf app-1 | [12/28/2024] [11:31:39 AM] [Nginx ] › ℹ info Reloading Nginx app-1 | [12/28/2024] [11:31:39 AM] [Express ] › ⚠ warning Command failed: certbot certonly --config "/etc/letsencrypt.ini" --work-dir "/tmp/letsencrypt-lib" --logs-dir "/tmp/letsencrypt-log" --cert-name "npm-17" --agree-tos --authenticator webroot --email "myemail@gmail.com" --preferred-challenges "dns,http" --domains "mydomain.com" app-1 | Saving debug log to /tmp/letsencrypt-log/letsencrypt.log app-1 | Some challenges have failed. app-1 | Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /tmp/letsencrypt-log/letsencrypt.log or re-run Certbot with -v for more details. ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/nginx-proxy-manager-NginxProxyManager#997
No description provided.