From b5356568d5370e03a7f0c2fbdf93296cd6cc7ab9 Mon Sep 17 00:00:00 2001 From: Mitchel Humpherys Date: Sun, 29 Sep 2019 12:06:07 -0700 Subject: [PATCH 1/2] docker_run.sh: Add env var to specify storage directory Currently `docker_run.sh` bind-mounts some directories rooted at the working directory when the script is invoked. Add an environment variable so that this storage location can be specified at invocation time without having to change to a different directory. Also creates PIHOLE_BASE if it doesn't exist already. --- README.md | 2 ++ docker_run.sh | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1b1b8a4..afdb934 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,8 @@ If you're using a Red Hat based distrubution with an SELinux Enforcing policy ad Volumes are recommended for persisting data across container re-creations for updating images. The IP lookup variables may not work for everyone, please review their values and hard code IP and IPv6 if necessary. +You can customize where to store persistent data by setting the `PIHOLE_BASE` environment variable when invoking `docker_run.sh` (e.g. `PIHOLE_BASE=/opt/pihole-storage ./docker_run.sh`). If `PIHOLE_BASE` is not set, files are stored in your current directory when you invoke the script. + Port 443 is to provide a sinkhole for ads that use SSL. If only port 80 is used, then blocked HTTPS queries will fail to connect to port 443 and may cause long loading times. Rejecting 443 on your firewall can also serve this same purpose. Ubuntu firewall example: `sudo ufw reject https` **Automatic Ad List Updates** - since the 3.0+ release, `cron` is baked into the container and will grab the newest versions of your lists and flush your logs. **Set your TZ** environment variable to make sure the midnight log rotation syncs up with your timezone's midnight. diff --git a/docker_run.sh b/docker_run.sh index 071f83d..0197f34 100755 --- a/docker_run.sh +++ b/docker_run.sh @@ -2,14 +2,17 @@ # https://github.com/pi-hole/docker-pi-hole/blob/master/README.md +PIHOLE_BASE=${PIHOLE_BASE:-$(pwd)} +[[ -d "$PIHOLE_BASE" ]] || mkdir -p "$PIHOLE_BASE" || { echo "Couldn't create storage directory: $PIHOLE_BASE"; exit 1; } + docker run -d \ --name pihole \ -p 53:53/tcp -p 53:53/udp \ -p 80:80 \ -p 443:443 \ -e TZ="America/Chicago" \ - -v "$(pwd)/etc-pihole/:/etc/pihole/" \ - -v "$(pwd)/etc-dnsmasq.d/:/etc/dnsmasq.d/" \ + -v "${PIHOLE_BASE}/etc-pihole/:/etc/pihole/" \ + -v "${PIHOLE_BASE}/etc-dnsmasq.d/:/etc/dnsmasq.d/" \ --dns=127.0.0.1 --dns=1.1.1.1 \ --restart=unless-stopped \ pihole/pihole:latest From 740248f18bf71b751a4ab9e44d504bc0c8cfb81b Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Mon, 11 May 2020 18:38:19 -0500 Subject: [PATCH 2/2] Add quote for path --- docker_run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker_run.sh b/docker_run.sh index 0197f34..7c7751e 100755 --- a/docker_run.sh +++ b/docker_run.sh @@ -2,7 +2,7 @@ # https://github.com/pi-hole/docker-pi-hole/blob/master/README.md -PIHOLE_BASE=${PIHOLE_BASE:-$(pwd)} +PIHOLE_BASE="${PIHOLE_BASE:-$(pwd)}" [[ -d "$PIHOLE_BASE" ]] || mkdir -p "$PIHOLE_BASE" || { echo "Couldn't create storage directory: $PIHOLE_BASE"; exit 1; } docker run -d \