Need to Reset Pihole Password After Container Restart

Every time I restart my container, pihole creates a random password and does not use the password in my compose file. Each time I have to reboot my server or restart pihole, I have to go in and reset its password.

Is there something I did wrong in my compose file?

version: "3"
services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    # For DHCP it is recommended to remove these ports and instead add: network_mode: "host"
    #ports:
    #  - "53:53/tcp"
    #  - "53:53/udp"
    #  - "67:67/udp" # Only required if you are using Pi-hole as your DHCP server
    #  - "80:80/tcp"
    network_mode: "host"
    environment:
      TZ: 'America/New York'
      WEBPASSWORD: password
    # Volumes store your data between container upgrades
    volumes:
      - './etc-pihole:/etc/pihole'
      - './etc-dnsmasq.d:/etc/dnsmasq.d'
    #   https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
    cap_add:
     # - NET_ADMIN # Required if you are using Pi-hole as your DHCP server, else not needed
    restart: unless-stopped

I'm not able to replicate the issue.

Just to be sure this is not caused by some "cached"/old info, can you please try using a different container name?

Example:
container_name: piholetest

Is that literally what is in your compose file, or is password actually a reference to a variable?

Is really qwerty1 but I didn’t want everyone to know my password. :woozy_face:

Sorry for necrobumping but i have the same issue:
my compose-config:

version: '3'

services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    ports:
      - "53:53"
      - "80:80"
      - "67:67"
    environment:
      - TZ:'Europe/Berlin'
      - WEBPASSWORD='mypassword'
      - REV_SERVER='true'
      - REV_SERVER_TARGET='192.168.178.1'
      - REV_SERVER_CIDR='192.168.178.0/24'
    volumes:
      - ./etc-pihole:/etc/pihole
      - ./etc-dnsmasq.d:/etc/dnsmasq.d
    dns:
      - 127.0.0.1
      - 1.1.1.1
    restart: unless-stopped
    hostname: pi.hole
    deploy:
        resources:
            limits:
              cpus: "1.0"
              memory: 512M
            reservations:
              cpus: "0.25"
              memory: 128M

and then when running docker compose up and then try to type in my password, it doesnt work.

cat-ing the ./etc-pihole/setupVars.conf , then resetting password and then re-setting the same password gives two different hashes pre and post reset:

 neko@debian:~/docker/test$ cat ./etc-pihole/setupVars.conf
INSTALL_WEB_INTERFACE=true
WEBPASSWORD=hashofpassword
PIHOLE_DNS_1=8.8.8.8
PIHOLE_DNS_2=8.8.4.4
PIHOLE_INTERFACE=eth0
QUERY_LOGGING=true
REV_SERVER='true'
REV_SERVER_TARGET='192.168.178.1'
REV_SERVER_CIDR='192.168.178.0/24'
neko@debian:~/docker/test$ sudo docker exec pihole sudo pihole -a -p

  [✓] Password Removed
neko@debian:~/docker/test$ sudo docker exec pihole sudo pihole -a -p Cobra112!
  [✓] New password set
neko@debian:~/docker/test$ cat ./etc-pihole/setupVars.conf
INSTALL_WEB_INTERFACE=true
WEBPASSWORD=differenthashthanbefore
PIHOLE_DNS_1=8.8.8.8
PIHOLE_DNS_2=8.8.4.4
PIHOLE_INTERFACE=eth0
QUERY_LOGGING=true
REV_SERVER='true'
REV_SERVER_TARGET='192.168.178.1'
REV_SERVER_CIDR='192.168.178.0/24'
BLOCKING_ENABLED=true

because i probably will not be the first or the last to have this issue: what am i doing wrong?
After the reset i can just log in.

Edit, by dumb idea i found out. my Password by the compose is set to literally being

'mypassword'

rather than mypassword

This is because you have a mix of : and = delimited variables in the yaml, and single quotes around just the right hand of the delimiter and not the entire line.

If you run docker container exec pihole bash -c 'env' you'll get a dump of all the environmen and variables set inside the container.