Pi-hole in a Docker Container

Installing Pi-hole as a Docker container is easy and do serve you well.

Pi-hole in a Docker Container
Photo by Taso Katsionis / Unsplash

Installation

You need to have Docker running. I'm using Dockge to control my containers, but you can also use Portainer.

Notes

  • Environment
    • TZ: Set the appropriate timezone for your location (see link of TZ codes),
    • Password: Set a password to access the web interface, or a random password will be issued for you (will be shown).
  • Volumes store your data between container upgrades volumes.
    For persisting Pi-hole's databases and common configuration file locations
    • Custom dnsmasq section, uncomment if you have custom dnsmasq config files that you want to persist. Not needed for most starting fresh with Pi-hole v6.
      If you're upgrading from v5 and have used this directory before, you should keep it enabled for the first v6 container start to allow for a complete migration. It can be removed afterward.
  • cap_add: See link. Required if you are using Pi-hole as your DHCP server, else not needed
services:
  pihole:
    container_name: pihole
    image: pihole/pihole:latest
    restart: unless-stopped
    ports:
      - "53:53/tcp"   # DNS Ports
      - "53:53/udp"   # DNS Ports
      - "80:80/tcp"   # Default HTTP Port
      - "443:443/tcp" # Default HTTPs Port. FTL will generate a self-signed certificate
      #- "67:67/udp". # Uncomment the below if using Pi-hole as your DHCP Server
      
    environment:
      TZ: 'Europe/London' # Edit to reflect your timezone
      FTLCONF_webserver_api_password: 'a long and complicated password'
      
    volumes:
      - './etc-pihole:/etc/pihole'
      # Custom dnsmasq section
      #- './etc-dnsmasq.d:/etc/dnsmasq.d' # Uncomment if for custom dnsmasq config
      
    cap_add:
      - NET_ADMIN

Login

http://<IP of Docker VM>/admin/


References

Pi-hole [1]


  1. Note GitHub, getting started docs ↩︎