(solved) Cannot reach pi-hole locally after docker-based installation

Good evening, forists.
My laptop is running a Debian based 64-bit Linux (Mx-19.4ahs).

Today I installed Docker and then pihole on this system. The whole thing seems to work as well, because when I type
$ docker-compose -f /opt/containers/pi-hole/docker-compose.yml up -d

I get a message that pi-hole is up to date:
pihole is up-to-date

for sure the whole thing:

$ docker-compose -f /opt/containers/pi-hole/docker-compose.yml up -d
pihole is up-to-date
docker@mxahs-docker:~
$

"mxahs-docker" is my computer's name.
I want to be able to access pi-hole locally on this laptop, so I don't want to make this laptop available as a pihole server for other devices on the network.

Till now I have not managed to access the webinterface of pi-hole on this computer in a browser.

I appreciate any advice on how to get this to work.

Greetings
Karl

Translated with www.DeepL.com/Translator (free version)

can you post your docker-compose.yaml file?

2 Likes

Can you describe the actual issue you have? From the topic name it seems like your cannot access Pi-hole from the container host? How did you try that?

Usually using 127.0.0.1:53 as DNS server should work to access a local instance, AFAIK also when it runs in a container.

Then your curent approach seems sensible.
Just installing Pi-hole won't coerce your clients to use it for DNS; it would just sit there and wait for requests that never arrive.
You'd have to configure either your router or each of your clients before they'd start making use of Pi-hole.

So in your case, you'd still have to point your laptop's DNS settings to Pi-hole, and for that to work, you'd also have to make your Pi-hole container's exposed ports accessible from your host.
(It would depend on your choice of Docker's network modes how you do that. As RonV42 has suggested, sharing your docker-compose would allow to better tip you in the right direction.)

If you didn't do the former, you wouldn't be able to access your Pi-hole's UI by its default name pi.hole, and without the latter, you won't be able to communicate with Pi-hole at all. i.e. nslookups would either not use Pi-hole or fail.

@RonV42
@MichaIng

Good morning,
first of all thank you very much for trying to help me.

@RonV42
You are asking about the docker-compose.yml:

version: "3"
# More info at https://github.com/pi-hole/docker-pi-hole/ and https://docs.pi-hole.net/
services:
pihole:
container_name: pihole
image: pihole/pihole:latest
restart: unless-stopped
ports:
- "53:53/tcp"
- "53:53/udp"
environment:
TZ: 'Europe/Berlin'
WEBPASSWORD: 'securepassword' # enter your password here
volumes:
- '/opt/containers/pi-hole/pihole/:/etc/pihole/'
- '/opt/containers/pi-hole/dnsmasq/:/etc/dnsmasq.d/'
dns:
- 127.0.0.1
- 1.1.1.1
127.0.0.1:53

@MichaIng

In a first step I would like to see the GUI of pi-hole, so I can make settings at all.

Regards
Karl

@Bucking_Horn
thank you very much too.

I will try today to follow your instruction.

Regards
Karl

I am assuming you are using the sample from:

GitHub - pi-hole/docker-pi-hole: Pi-hole in a docker container

You seem to be missing port 80 in your configuration file. Below is the one from the article, if it runs successfully you should be able to get to the web interface by using the local ip address of your computer:

http://192.168.x.x/admin

version: "3"

# More info at https://github.com/pi-hole/docker-pi-hole/ and https://docs.pi-hole.net/
services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "67:67/udp"
      - "80:80/tcp"
    environment:
      TZ: 'America/Chicago'
      # WEBPASSWORD: 'set a secure password here or it will be random'
    # Volumes store your data between container upgrades
    volumes:
      - './etc-pihole/:/etc/pihole/'
      - './etc-dnsmasq.d/:/etc/dnsmasq.d/'
    # Recommended but not required (DHCP needs NET_ADMIN)
    #   https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
    cap_add:
      - NET_ADMIN
    restart: unless-stopped
1 Like

@RonV42

WOW, with your script IT WORKS!!!!!!!
I can open the GUI.

Now I will try to set pi-hole to use local ip.

Thank you so much!!!
Karl

@RonV42
Good afternoon,
now I can open the GUI.
But even though I entered my password in your script (after removing the "#" at the beginning of the line, of course), I can't log in with that password.

Pi-hole writes:
Forgot password?
After installing Pi-hole for the first time, a password is generated and displayed to the user. The password cannot be retrieved later on, but it is possible to set a new password (or explicitly disable the password by setting an empty password) using the command

sudo pihole -a -p

When I type sudo pihole -a -p into the terminal, I get the error message:
$ pihole -a -p
bash: pihole: command not found
docker@mxahs-docker:~
$ sudo pihole -a -p
sudo: pihole: command not found
docker@mxahs-docker:~
$

What can I do?

Regards
Karl

You need to edit your yaml file and provide the password on this line:

WEBPASSWORD: 'securepassword' # enter your password here

I did exactly this
Must I write the apostrophs ' ' as well or Password without them?

docker exec -it <container_name> pihole -a -p

That would allow you to change the password in the container.

But in the config file here is an example:

WEBPASSWORD: letmein # <-- Add password (if required)

the config file now contains:

version: "3"

# More info at https://github.com/pi-hole/docker-pi-hole/ and https://docs.pi-hole.net/
services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    ports:
      - "53:53/tcp"
      - "53:53/udp"
      - "67:67/udp"
      - "80:80/tcp"
    environment:
      TZ: 'Europe/Berlin'
      WEBPASSWORD: letmein # <-- Add password (if required)
    # Volumes store your data between container upgrades
    volumes:
      - './etc-pihole/:/etc/pihole/'
      - './etc-dnsmasq.d/:/etc/dnsmasq.d/'
    # Recommended but not required (DHCP needs NET_ADMIN)
    #   https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
    cap_add:
      - NET_ADMIN
    restart: unless-stopped

When I type in pihole passwword request:
letmein
I get
Wrong password!

I apologize for asking again and again.
I am knew to docker.

The normal pi-hole installation (without docker) was no problem for me.
I succeeded on several computers.

But I thought it is time for me to get familiar with docker.
Thank you for all your patience!
Karl

Hurrah,
your advice
$ docker exec -it pihole pihole -a -p
did the job.

Thank you so much!
Have a nice sunday
Karl

2 Likes

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.