Skip to content

Commit

Permalink
Merge pull request #140 from diginc/dev
Browse files Browse the repository at this point in the history
Dev fixes for ARM & Alpine
  • Loading branch information
diginc authored May 29, 2017
2 parents fcb62ee + 48d5f10 commit 3da2764
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 8 deletions.
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,20 @@ IP_LOOKUP="$(ip route get 8.8.8.8 | awk '{ print $NF; exit }')" # May not work
IPv6_LOOKUP="$(ip -6 route get 2001:4860:4860::8888 | awk '{ print $10; exit }')" # May not work for VPN / tun0
IP="${IP:-$IP_LOOKUP}" # use $IP, if set, otherwise IP_LOOKUP
IPv6="${IPv6:-$IPv6_LOOKUP}" # use $IPv6, if set, otherwise IP_LOOKUP
DOCKER_CONFIGS="$(pwd)" # Default of directory you run this from, update to where ever.
docker run -d \
--name pihole \
-p 53:53/tcp -p 53:53/udp -p 80:80 \
-v "$(pwd)/pihole/:/etc/pihole/" \
-v "$(pwd)/dnsmasq.d/:/etc/dnsmasq.d/" \
-e ServerIP="${IP:-$(ip route get 8.8.8.8 | awk '{ print $NF; exit }')}" \
-e ServerIPv6="${IPv6:-$(ip -6 route get 2001:4860:4860::8888 | awk '{ print $10; exit }')}" \
-v "${DOCKER_CONFIGS}/pihole/:/etc/pihole/" \
-v "${DOCKER_CONFIGS}/dnsmasq.d/:/etc/dnsmasq.d/" \
-e ServerIP="${IP}" \
-e ServerIPv6="${IPv6}" \
--restart=always \
diginc/pi-hole:alpine
```

Volumes aren't required but are recommended for persisting data across docker re-creations for updating images. This is just an example and might need changing. As mentioned on line 2, the auto IP_LOOKUP variable may not work for VPN tunnel interfaces.
**This is just an example and might need changing.** Volumes are stored in the directory $DOCKER_CONFIGS and aren't required but are recommended for persisting data across docker re-creations for updating images. As mentioned on line 2, the auto IP_LOOKUP variable may not work for VPN tunnel interfaces.

**Automatic Ad List Updates** - since 3.0+ release cron is baked into the container and will grab the newest versions of your lists and flush your logs. **Set TZ** environment variable to make sure the midnight log rotation syncs up with your timezone's midnight.

Expand Down Expand Up @@ -134,6 +135,12 @@ The webserver and DNS service inside the container can be customized if necessar

Similarly for the webserver you can customize configs in /etc/nginx (*:alpine* tag) and /etc/lighttpd (*:debian* tag).

### Systemd init script

As long as your docker system service auto starts on boot and you run your container with `--restart=always` your container should always start on boot and restart on crashes. If you prefer to have your docker container run as a systemd service instead add the file [pihole.service](https://raw.githubusercontent.com/diginc/docker-pi-hole/master/pihole.service) to "/etc/systemd/system"; customize whatever your container name is and remove `--restart=always` from your docker run. Then after you have initially created the docker container using the docker run command above, you can control it with "systemctl start pihole" or "systemctl stop pihole" (instead of `docker start`/`docker stop`). You can also enable it to auto-start on boot with "systemctl enable pihole" (as opposed to `--restart=always` and making sure docker service auto-starts on boot).

NOTE: After initial run you may need to manually stop the docker container with "docker stop pihole" before the systemctl can start controlling the container.

## Development

[![Build Status](https://api.travis-ci.org/diginc/docker-pi-hole.svg?branch=dev)](https://travis-ci.org/diginc/docker-pi-hole) If you plan on making a contribution please pull request to the dev branch. I also build tags of the dev branch for bug fix testing after merges have been made:
Expand Down
1 change: 1 addition & 0 deletions debian-armhf.docker
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN apt-get update && \
apt-get install -y wget curl net-tools cron && \
curl -L -s $S6OVERLAY_RELEASE \
| tar xvzf - -C / && \
ln /lib/ld-linux-armhf.so.3 /lib/ld-linux.so.3 && \
docker-install.sh && \
rm -rf /var/cache/apt/archives /var/lib/apt/lists/*

Expand Down
5 changes: 3 additions & 2 deletions docker_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ IP_LOOKUP="$(ip route get 8.8.8.8 | awk '{ print $NF; exit }')" # May not work
IPv6_LOOKUP="$(ip -6 route get 2001:4860:4860::8888 | awk '{ print $10; exit }')" # May not work for VPN / tun0
IP="${IP:-$IP_LOOKUP}" # use $IP, if set, otherwise IP_LOOKUP
IPv6="${IPv6:-$IPv6_LOOKUP}" # use $IPv6, if set, otherwise IP_LOOKUP
DOCKER_CONFIGS="$(pwd)" # Default of directory you run this from, update to where ever.

echo "IP: ${IP} - IPv6: ${IPv6}"

# Default ports + daemonized docker container
docker run -d \
--name pihole \
-p 53:53/tcp -p 53:53/udp -p 80:80 \
-v "$(pwd)/pihole/:/etc/pihole/" \
-v "$(pwd)/dnsmasq.d/:/etc/dnsmasq.d/" \
-v "${DOCKER_CONFIGS}/pihole/:/etc/pihole/" \
-v "${DOCKER_CONFIGS}/dnsmasq.d/:/etc/dnsmasq.d/" \
-e ServerIP="${IP:-$(ip route get 8.8.8.8 | awk '{ print $NF; exit }')}" \
-e ServerIPv6="${IPv6:-$(ip -6 route get 2001:4860:4860::8888 | awk '{ print $10; exit }')}" \
--restart=always \
Expand Down
13 changes: 13 additions & 0 deletions pihole.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=pihole
Requires=docker.service multi-user.target
After=docker.service network-online.target dhcpd.service

[Service]
Restart=always
ExecStart=/usr/bin/docker start -a pihole
ExecStop=/usr/bin/docker stop -t 2 pihole

[Install]
WantedBy=multi-user.target

2 changes: 1 addition & 1 deletion s6/alpine-root/etc/services.d/dnsmasq/run
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

s6-echo "Starting dnsmasq"

s6-setuidgid dnsmasq dnsmasq -7 /etc/dnsmasq.d --no-daemon
s6-setuidgid root dnsmasq -7 /etc/dnsmasq.d --no-daemon

0 comments on commit 3da2764

Please sign in to comment.