Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

https://hub.docker.com/r/pihole/pihole/

https://www.smarthomebeginner.com/run-pihole-in-docker-on-ubuntu-with-reverse-proxy/#Step_1_Modify_Ubuntu_Network_Configuration

Setup:

There is a special step which is to disable listening on port 53 on the local server or the container won't start!

sudo mv /etc/resolv.conf /etc/resolv.conf.bak
sudo systemctl disable systemd-resolved.service
sudo systemctl stop systemd-resolved.service


Docker-Compose:

WD=/opt/pihole
mkdir -p $WD/{setup,etc,dnsmasq.d}
cd $WD/setup
cat << 'EOF' >docker-compose.yaml
version: '3.7'

services:
 pihole:
    container_name: pihole
    image: pihole/pihole:latest
    hostname: pihole
    ports:
      - '53:53'
      - '8748:80'
      - '4379:443'
    volumes:
      - type: bind
        source: /opt/pihole/etc/
        target: /etc/pihole
      - type: bind
        source: /opt/pihole/dnsmasq.d/
        target: /etc/dnsmasq.d/
    environment:
      - 'TZ=${TZ}'
      - 'WEBPASSWORD=${WEBPASSWORD}'
    dns:
      - 127.0.0.1
      - 1.1.1.1

EOF
chmod +x docker-compose.yaml

cd $WD/setup
cat << 'EOF'>.env
TZ=America/Whitehorse
WEBPASSWORD=PWD
EOF
chmod +x .env

SystemD:

WD=/opt/pihole/setup
cat << EOF >$WD/pihole.service.setup.sh
cat << EOL >/lib/systemd/system/pihole.service
[Unit]
Description=pihole_Docker
Requires=docker.service network-online.target

[Service]

Restart=on-abnormal
ExecStart=/usr/bin/docker-compose --project-name pihole --project-directory $WD -f $WD/docker-compose.yaml up
ExecStop=/usr/bin/docker-compose --project-name pihole --project-directory $WD -f $WD/docker-compose.yaml stop

[Install]
WantedBy=multi-user.target
EOL
systemctl enable pihole
systemctl restart pihole
systemctl status pihole
EOF
chmod +x $WD/pihole.service.setup.sh
$WD/pihole.service.setup.sh

XYMon:

nano /etc/xymon/analysis.cfg && systemctl restart xymon xymon-client
        PROC pihole

Bash CLI Alias:

echo 'alias piholecli="docker exec -it pihole /bin/bash"' >> ~/.bashrc
source ~/.bashrc
  • No labels