chriscrowe / docker-pihole-unbound

Run Pi-Hole + Unbound on Docker
1.08k stars 286 forks source link

Hostname Variable #234

Open blusls79 opened 11 months ago

blusls79 commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

Tried that. That doesn’t work either. Hostname variable is already in place. See screenshots below. I am using Portainer if that makes a difference. I have also updated the container name as well to match. Not that I thought that would work. It @. @.

From: xteriormask4eva @.> Sent: Thursday, January 4, 2024 9:03 PM To: chriscrowe/docker-pihole-unbound @.> Cc: Scott L. Smith @.>; Author @.> Subject: Re: [chriscrowe/docker-pihole-unbound] Hostname Variable (Issue #234)

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

— Reply to this email directly, view it on GitHubhttps://github.com/chriscrowe/docker-pihole-unbound/issues/234#issuecomment-1878091183, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AMBSOWFNGHQMZUZTPLS454DYM53NNAVCNFSM6AAAAABBJLYAPSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZYGA4TCMJYGM. You are receiving this because you authored the thread.Message ID: @.**@.>>

xteriormask4eva commented 11 months ago

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

ChevySSinSD commented 5 months ago

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