Skip to content
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

Hostname Variable #234

Open
blusls79 opened this issue Jan 1, 2024 · 4 comments
Open

Hostname Variable #234

blusls79 opened this issue Jan 1, 2024 · 4 comments

Comments

@blusls79
Copy link

blusls79 commented Jan 1, 2024

Hi,

Happy New Year and thanks for all your hard work on this. I noticed that the hostname does not take when applied in the config. When the container starts, it gets a random name, as opposed to the configured hostname in the compose file. Is there a fix for this? Pardon my OCD on this light issue.

image image
@xteriormask4eva
Copy link

that looks like the container ID i'm sure you probably already did this but did you make sure to replace the host name in your .env file? usuallly when you dont enter anything there it just uses the container ID...
If thats the case I think if you change it from the file and redeploy should fix it

@blusls79
Copy link
Author

blusls79 commented Jan 5, 2024 via email

@xteriormask4eva
Copy link

Ahh fair enough I did not use portainers sorry I could not be more help :(

@ChevySSinSD
Copy link
Contributor

Hello, the pi-hole hostname shown on the web dashboard shows the hostname of the docker container. Setting the HOSTNAME environment variable alone does not change the hostname of the docker container.

Setting Hostname for Container

You can set the hostname of the pi-hole docker container to your HOSTNAME environment variable as follows:

services:
  pihole:
    image: cbcrowe/pihole-unbound   # Load the latest pihole unbound version
    hostname: ${HOSTNAME}           # Set hostname of docker container to the HOSTNAME env variable
    # The rest of your stack configuration goes below here

In portainer, add the hostname line to the stack in the web editor section (above the environment variable section you have in the screenshot).
Docker docs network configuration reference

Note: VIRTUAL_HOST environment variable

Pi-hole docker docs optional env variables documentation
By default, the pi-hole document container adds HOSTNAME as a 'virtual host.' This allows you to add to the whitelist/blacklist when accessing your pihole via the hostname url. If you do not want that, you will need to change the VIRTUAL_HOST environment variable.

Variable Default Value Description
VIRTUAL_HOST ${HOSTNAME} your.host.name What your web server 'virtual host' is, accessing admin through this Hostname/IP allows you to make changes to the whitelist / blacklists in addition to the default 'http://pi.hole/admin/' address

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants