Sign inSign up

theonlysinjin/docker-pihole-dns-shim

By theonlysinjin

•Updated 6 months ago

Synchronise records found through docker labels with pihole's custom dns and cname records.

Image
1

10.0K

theonlysinjin/docker-pihole-dns-shim repository overview

⁠docker-pihole-dns-shim

Synchronise records founds through docker labels with pihole's custom dns and cname records.
You can find the project on GitHub⁠

⁠How to get started

⁠Find your secret pihole token

  • Navigate to the api tab⁠ in your pihole settings
  • Click the Show API token button
  • Copy the Raw API Token
  • Use this as PIHOLE_TOKEN

⁠Run

cli

docker run \
  -l "pihole.custom-record=[[\"pihole-dns-shim.lan\", \"127.0.0.1\"]]" \
  -e PIHOLE_TOKEN="" \
  -e PIHOLE_API="http://pi.hole:8080/admin/api.php" \
  -e STATE_FILE="/state/pihole.state" \
  -v /var/run/docker.sock:/var/run/docker.sock:ro \
  theonlysinjin/docker-pihole-dns-shim

docker-compose.yml

services:
  pihole-dns-shim:
    container_name: "pihole-dns-shim"
    image: theonlysinjin/docker-pihole-dns-shim
    restart: unless-stopped
    labels:
      - pihole.custom-record=[["pihole-dns-shim.lan", "127.0.0.1"]]
    environment:
      PIHOLE_TOKEN: "${PIHOLE_TOKEN}"
      PIHOLE_API: "${PIHOLE_API}"
      # LOGGING_LEVEL: "DEBUG"
      # STATE_FILE: "/state/pihole.state"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"

⁠Label

Add records to pihole by labelling your docker containers, you can add as many labels(records) to individual containers as you need.
An example of the (json-encoded) label is as follows:

pihole.custom-record:
  - ["pihole-dns-shim.lan", "127.0.0.1"]
  - ["pihole-dns-shim.lan", "www.google.com"]

as a docker label:

"pihole.custom-record=[[\"pihole-dns-shim.lan\", \"127.0.0.1\"], [\"pihole-dns-shim.lan\", \"www.google.com\"]]"

⁠Development

⁠Debug

You can turn on extra logging by setting the log level to DEBUG,
Set an env variable in the container with LOGGING_LEVEL="DEBUG"

Tag summary

Content type

Image

Digest

sha256:0caf89564…

Size

29.4 MB

Last updated

6 months ago

docker pull theonlysinjin/docker-pihole-dns-shim