-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set PUID and PGID as Variables #328
Comments
What are the deafult PUID and PGID that Pi-Hole runs under right now? |
The services run as mix of
|
@diginc Thanks |
That would explain why I can't do anything in the webgui (adding white list) etc. for example as the user is not correctly set |
Similar stuff - I deploy on Qnap NAS + VPS. I think it would be nice to have ability to specify UID & GID. I hope this issue is still valid |
Still on my board. FTL's service script (docker specific s6) needs to be updated to run as pi-hole user to accommodate not having a mix of 3 different users processes. |
@diginc thank you for clarification and overall great work on that :) |
Same thing happens on QNAP NAS, the GUID en PUID aren't set so the files pihole needs in /etc/pihole are pretty much read only to the docker image if you want to mount them to store the data outside of the image. You can clearly see pihole wanting to create files with GID 999, while that one doesn't exist on the NAS. |
same thing happening on docker in ubuntu, every time i restart the service it can't read previosly saved config files i assume, so everything is reset and a new password regenerated. great job with pi-hole, can t wait to be able to fully use it |
As this is not a synology specific issue would it be possible to rename that issue? Something like "Use provided host PID / GID to allow host compatible file access" seems to me more meaningful for this feature request. The mentioned "magic" from linuxserver.io is mainly the usage of a user account "abc" which the tweak to the given PID / GID, see https://github.com/linuxserver/docker-baseimage-alpine/blob/master/root/etc/cont-init.d/10-adduser
Sidenote: Best practice is to create a "technical docker user" on the NAS / host and use the values of that account for the containers. |
And is there currently a workaround to overcome the issue with permission 999 on shared folder "pihole"? |
My last post in that thread leads to this post and it's reply about tweaking nas permissions to resolve folder share permissions conflicting with docker permissions. |
I solved this problem in the way that I executed this command before docker-compose on the shared folder: This allowed the system to create all files with necessary permissions to execute. And my volume share for this looks like this: |
Any movement on this? |
Diginc, do we need to add an entrypoint to |
Using the linuxserver io style adduser script works really well as long as your programs actually run as that same defined user. Since this was last discussed we added customizing dnsmasq / FTL's user feature which helps. Spitballing the logic: IF PUID / PGID is passed in, it could modify the pre-existing pihole user to user those IDs and then force the dnsmasq user to pihole. Next up is probably customizing www-data lighttpd user customization before this'll work. That is a fairly simple sed command. |
@diginc It sounds like everything I need has been implemented, just sanity checking with you. Adding
to my |
@JCass45 Only the DNSMASQ_USER variable has been added so far. The PUID and GUID scripts haven't been added yet. |
Do we know when PUID and PGID is going to be implemented as I currently keep getting: cp: cannot create regular file '/etc/dnsmasq.d/01-pihole.conf': Permission denied Even with DNSMASQ_USER set to 1000 |
I am another +1 for this. I am trying to use pihole in a rootless container w/ Podman. I currently cant do this because there are three relevant user/group IDs inside the pi-hole container. The only way to get pihole working is - sadly - to use |
This permissions hell is a mess. And chmod'ing 777 is not a proper solution, it's a serious security issue. |
It would be awesometo see this fixed up. Having contorll over this make it really easy for this to slot straight into existing convensions. |
hi @edgd1er
the mounts are nfs mounts
here is output from ls -la within container
I have no idea why the log error is gone but here is the log
I can use the webinterface now with the dev image but whitelisting is not working with this image .... the rights looking ok for me |
This should have been chowned when FTL started. We may have missed it, I'll check later! What is the exact error you get when whitelisting? |
Hi @PromoFaux |
@nixmomo , Could you test with local storage as I suspect your problem may be due to nfs filesystem rights ? |
@edgd1er its a nfs v3 mount so it is mounted as a local folder but i tried with a real local folder and its the same issue |
This experimental support is now in |
FWIW this worked first try for me. Thanks!!! |
The "While executing: attempt to write a readonly database here is the debug log if it helps |
ok, it works if i move the files to local folder but there it struggles with the rpimonitor user (both using 999 as uid) thats why i want to change... |
this link: https://serverfault.com/questions/240897/how-to-properly-set-permissions-for-nfs-folder-permission-denied-on-mounting-en may give you some hints on how to tackle right permissions on nfs. uid/gid must match between the containers and the nfs server. if not, ,anonuid=1000,anongid=1000 may be a solution. uid/gid 1000 must have read,right permissions on the nfs dirs/files. |
hmm that cant be the point... i have no_root_squash and the ownership on the nfs mounts are the same that i set in pihole configs and on the nfs server are they set to the same uid/guid i configured for pihole and the folder on top has a 777 write permission.... i can create files from within the docker container in the mounted volumes too so it can't be a nfs problem.. that makes absolutly no sense |
The host volume has to bind mount into the container and it introduces some odd behavior with nfs. But docker supports nfs mounting the volume from within the container. You can do it from the docker command line or from docker compose if you are using that. Just google how to mount nfs into a docker container. Switch to that and this should go away, plus you can drop allowing the root access which is dangerous. I feel compelled to add that there are many reasons for an nfs mount to have issues. Those issues will take out your entire network when pihole stops working. Not to mention that you will have to carefully get that nfs location mounted without dns since you have to do it before pihole is started. I'm not sure what you are gaining here but I wouldn't do this. |
Working for me, thanks a lot Only problem, I tried to get the same UID/GID for WEB and PIHOLE which is not working. After I figured out that it creates the same UID and GID in passwd and groups, I removed WEB_UID and WEB_GID (which is almost useless) all is working. |
I'll take a look at that soon. |
Just for reference: all of the sudden I couldn't edit any settings. I suppose it has something to do with me changing the docker-volumes location (didn't change permissions though). For whatever reason stopping, removing and pruning the pihole-image and redownloading it, helped... I checked on the permissions of |
When I set PIHOLE_GID=1001 it reverts to GID of 999 and messes up my host volume group permissions. If I set PIHOLE_GID=1000 it correctly sets the GID to 1000 but that is not what I want on the host directory group permission. |
this feature has never worked very well.... thats the reason why i use unbound dns .... i love pihole but it is more a fun project ... in german we call it "frickelei" .... unbound dns is very stable and can handle all the pihole lists too and it has a HA feature and so on.... and all what i need is a stable working dns blocking function and the possibility to add local domains.... if unbound is not working ini your case, just look into adguard....its more stable and handles the gid and uid perfectly. |
Sorry you had a bad experience with free open source software. There are a number of other options like AdGuard or NextDNS however you are sending your data to other parties with those. What ever you decide to do, please make sure that you use some kind of software to help protect your privacy online. |
Can you please post your docker compose or docker run so we can try to assist you? Thanks! |
Well, for me pi-Hole is working fine within the docker container. I just had to make sure to forward those few hosts Portainer needs in case no DNS is available (pi-Hole container down when updating or altering settings). I also solved that issue by I think setting permissions on the file system (configs are written to a mounted volume in my case), because I just checked and I haven't specified any GID/PID in the environment arguments section of my docker-compose file. |
thanks for the hint but none of the called software calls home if you don't want to .... at the end it do the same like pihole. but i always have a pihole instance running to keep an eye on it. i'm sure that i use pihole in feature again as primary resolver / adblocker but before it is needed to fix all the broken things (pid / guid bugs, nfs support for storing configs) and an ha option (master slave sync maybe) |
This results in correct permissions on etc-pihole but etc-dnsmasq.d are still root/root
|
isn't it the wrong image? i'm not sure but is it merged into latest? |
?? 7 releases since then! Do you specifically mean this PR? That was released with |
I’m using :latest I commented on this thread rather than opening a new issue. |
There is a separate env setting DNSMASQ_USER for changing the dnsmasq user because on some systems dnsmasq won't work right if it is not root. I have it unset and I get root/root like you stated too. Although elsewhere here I see a statement it defaults to pihole, I think that must not be true. Try setting this to pihole. By the way this reverting to 999 issue doesn't seem to make sense to me and I don't see that in the info you shared. Could you show that one? Is the disk you are mapping a remote mounted volume by any chance? |
https://github.com/pi-hole/docker-pi-hole/blob/master/Dockerfile#L41
Yeah, I have the Pi-hole container running on my Synology (DSM7) and I have to set |
This is a...
Description
So I'm addressing a few things in this one issue, which I understand is not ideal.
Could you please add the PUID (Process User ID) and PGID (Process Group ID) variables? I tell you why.
I use Docker on my Synology NAS and for the life of me, I cannot get it to work.
I keep getting the following error:
[ERROR]: Unable to parse results from queryads.php: Unhandled error message (Invalid domain!)
I've therefore set the logs to be external with "/volume1/docker/pihole/logs/:/var/log/", however I then run into the problem that it cannot start because pihole doesn't have access to the logs (even though I set the permission to 777 for the directory and everything in it.)
`
Expected Behavior
Docker processes should run under the user id and group ID values specified in the environmental variables
Actual Behavior
It doesn't
Possible Fix
Add the variables. Many docker images have these variables, especially those from https://www.linuxserver.io/our-images if you need examples
Steps to Reproduce and debugging done
e.g. your docker run command, pages to visit, CLI commands you ran
There's not much to do as I can't even access the webpage directly after creating the image. FYI, I do not have DNS or DHCP running on my NAS.
This is the create command that I used:
sudo docker run -d \ --name pihole \ -p 53:53/tcp -p 53:53/udp \ -p 67:67/udp \ -p 32777:80 \ -p 32778:443 \ -v "/volume1/docker/pihole/pihole/:/etc/pihole/" \ -v "/volume1/docker/pihole/dnsmasq.d/:/etc/dnsmasq.d/" \ -e ServerIP="${IP}" \ -e TZ=Europe/Amsterdam \ -e DNS1=208.67.222.222 \ -e DNS2=208.67.220.220 \ -e PUID=1033 \ -e PGID=65540 \ --restart=unless-stopped \ --cap-add=NET_ADMIN \ pihole/pihole:latest
Debug steps I have tried
docker run
example in the readme (removing any customizations I added)Context and extra information
#271 #267 #85
Your Environment
The text was updated successfully, but these errors were encountered: