-
-
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
Web password is regenerated every time the container is recreated #364
Comments
You can set the password in something like docker-compose?
|
Would it be possible to not set the password, ie. use the one configured? Perhaps test if the config file has a |
@nxadm yeah, that's pretty much what I'm doing now, but it forces you to hard code that password in the compose file |
@ericparton It seems to me you need to put it somewhere. You can have a look at things like vault if you want to centralize your secrets. |
@nxadm but it's already stored in the config file - passing it in via. the environment should only be a one-time thing. The config file is, in my case, already mounted in using a volume. |
This is happening to me as well, for now Im just adding it to the docker-compose environment params. However I also noticed that when the container restarts or is updated, the selections of dns server on this page: Where is these data stored? Is it not |
On my setup:
|
In my compose file I don’t have the dnsmasq file mapped. Maybe that’s it. I’ll try it soon. I like your org structure on your host machine. I’m gonna use that. Thanks |
Adding the dnsmasq.d volume mount solved my issue! Thanks @nxadm |
The problem with the re-genarated password still exists, because that is how it currently is setup. In start.sh the first command issued is generate_password, which doesn't check if there is a password in the config file: docker-pi-hole/bash_functions.sh Lines 234 to 240 in 17cc8a2
This then gets used by setup_web_password: docker-pi-hole/bash_functions.sh Lines 242 to 261 in 17cc8a2
This of course is the same for other settings like DNS servers to use, web port and the likes. In my opinion, the first thing that start.sh should check if there is a config file and abort generating and setting stuff from the env vars should be disabled in that case. Please only generate a config if there is no existing config! If there is already such a feature implemented and I didn't see it, I guess that my issue is related to #328 |
The "fix" should be straight forward. However, in my case I have no problems with providing it through a compose file or Hashicorp's Vault (if I want it centralized). However, the clear-text password is needed by the application and I struggle to see the difference between a compose file (chmod 400) and a file on a mounted volume. |
I know we are talking about an app most of us are deploying on the local home network without outside access. But: You store the clear-text password on the filesystem with a docker-compose, pi-hole saves it as a double-hashed string. Not the most secure thing, but certainly a lot better than clear-text. The Vault is nice if the execution of the Setting a fixed password is clearly a workaround. But all other long running docker containers on my systems save their important stuff in their volumes and load their settings from there after a re-generation (aka "updating") of the container. I've never changed a setting by removing the container and starting it with different env vars. What's the point of using volumes then? |
I see what you mean. (When using Vault you can use https://github.com/hashicorp/consul-template to wrap the actual application so no bash history or enviroment variables are set. This is more FYI than an answer to your requirements.) |
It has been two months and nothing happened. If it is okay I would try and write up a PR for this. I'd add a mechanism to the start.sh which checks if there is a config. If it's there it will ignore any ENV variables. concerning the config files. |
Sorry for no action for so long, contributions by pull request are greatly appreciated. Would an escape hatch design to skip the web password setup function based off an ENV work instead? It is probably simpler to implement and I've seen the need for this in other cases and even wrote one. docker-pi-hole/bash_functions.sh Lines 283 to 292 in 17cc8a2
To make this scale up I think SKIP_SETUP_WEB_PASSWORD for your case and SKIP_ should be the convention. |
They way I learned to use docker images is just start it with the bare minimum. Just set what you need to get into the app, and change the settings in there. That way you start the container the same way every time. Also the docker start script doesn't need to change every time something changes in the way the apps configuration mechanism changes. If I want to change something, why should I want to stop my DNS server and start with a fresh container? Why recommending a mounted volume for the configuration if it doesn't persist? If there is a config, don't touch it. I just had a look at the most popular images on dockerhub using ENVs: mongo, mysql and in 12th place, postgres. They either say |
Gotcha, yeah we can make this work with a check against a password already being set. I think the same approach could be taken for many of the other env variables / setupVar.conf settings but that maybe best saved for a larger refactor. For now I'll get web password done. |
Signed-off-by: Adam Hill <[email protected]>
Please try out |
Yes, the web password didn't change |
This is a...
Description
I'm using docker compose to manage an installation of pihole, but every time the container needs to be recreated as the result of an update to the container or a configuration change, the web password is set to a new random value. Per the documentation, I'm mounting a persistent volume at /etc/pihole, which does save the rest of my settings, but just not the web password.
Expected Behavior
The web password is stored in somewhere in /etc/pihole and persisted with the rest of the configuration if a volume is mounted there.
Actual Behavior
The web password is not persisted with the rest of the configuration and is always regenerated when a new container is created, even if the container is reusing the configuration from a mounted volume.
Steps to Reproduce and debugging done
Debug steps I have tried
docker run
example in the readme (removing any customizations I added)Context and extra information
There is a workaround by setting the WEBPASSWORD variable, but you have to then hard code a password somewhere.
Your Environment
The text was updated successfully, but these errors were encountered: