template.yaml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. ---
  2. kind: compose
  3. schema: "1.1"
  4. metadata:
  5. name: Pihole
  6. description: >
  7. Network-wide advertisement and internet tracker blocking application that functions as a DNS blackhole.
  8. Provides DNS-level content filtering for all network devices, improving browsing performance, privacy, and security.
  9. Supports custom blocklists, whitelists, and seamless integration with existing network infrastructure.
  10. Project: https://pi-hole.net/
  11. Documentation: https://docs.pi-hole.net/
  12. GitHub: https://github.com/pi-hole/pi-hole
  13. version: 2025.08.0
  14. author: Christian Lempa
  15. date: '2025-09-28'
  16. tags:
  17. - dns
  18. - ad-blocking
  19. draft: false
  20. next_steps: |
  21. {% if swarm_enabled -%}
  22. 1. Create Docker Swarm secret for admin password:
  23. echo "{{ webpassword }}" | docker secret create {{ webpassword_secret_name }} -
  24. (Or use the generated .env.secret file)
  25. 2. Deploy to Swarm:
  26. docker stack deploy -c compose.yaml pihole
  27. 3. Verify deployment:
  28. docker service ls
  29. docker service logs pihole_{{ service_name }}
  30. 4. Access web interface:
  31. {% if network_mode == 'macvlan' -%}https://{{ network_macvlan_ipv4_address }}/admin/login
  32. {%- elif traefik_enabled == True -%}https://{{ traefik_host }}/admin/login
  33. {%- else -%}https://localhost:{{ ports_https }}/admin/login{%- endif %}
  34. 5. Login password: Stored in Docker secret '{{ webpassword_secret_name }}'
  35. 6. Configure devices to use your swarm node's IP address as DNS server
  36. {% else -%}
  37. 1. Start: docker compose up -d
  38. 2. Access web interface:
  39. {% if network_mode == 'macvlan' -%}https://{{ network_macvlan_ipv4_address }}/admin/login
  40. {%- elif traefik_enabled == True -%}https://{{ traefik_host }}/admin/login
  41. {%- else -%}https://localhost:{{ ports_https }}/admin/login{%- endif %}
  42. 3. Login password: {{ webpassword }}
  43. 4. Configure devices to use your host's IP address as DNS server
  44. {% endif -%}
  45. spec:
  46. general:
  47. vars:
  48. service_name:
  49. default: "pihole"
  50. container_name:
  51. default: "pihole"
  52. admin_settings:
  53. description: "Admin Pi-hole Settings"
  54. required: true
  55. vars:
  56. webpassword:
  57. description: "Web interface admin password"
  58. type: str
  59. sensitive: true
  60. default: ""
  61. autogenerated: true
  62. traefik:
  63. vars:
  64. traefik_host:
  65. default: "pihole.home.arpa"
  66. network:
  67. vars:
  68. network_mode:
  69. extra: "If you need DHCP functionality, use 'host' or 'macvlan' mode"
  70. network_name:
  71. default: "pihole_network"
  72. ports:
  73. needs: "network_mode=bridge"
  74. vars:
  75. ports_https:
  76. description: "External HTTPS port"
  77. type: int
  78. default: 8443
  79. extra: "Only used if Traefik is not enabled"
  80. ports_dns:
  81. description: "External DNS port"
  82. type: int
  83. default: 53
  84. ports_ntp:
  85. description: "External NTP port"
  86. type: int
  87. default: 123
  88. swarm:
  89. vars:
  90. swarm_placement_host:
  91. required: true
  92. webpassword_secret_name:
  93. description: "Docker Swarm secret name for admin password"
  94. type: str
  95. default: "pihole_webpassword"