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.
This commit is contained in:
Mitchel Humpherys 2019-09-29 12:06:07 -07:00
parent 49ed8a0b2c
commit b5356568d5
2 changed files with 7 additions and 2 deletions

View File

@ -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.

View File

@ -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