From cfba2f1ceb899cead2148e70732a4a62a0b43512 Mon Sep 17 00:00:00 2001 From: Tom Moore Date: Wed, 24 May 2017 10:07:49 -0400 Subject: [PATCH 1/3] Updated the docs to use the predefined env variables, and to keep in line with later path recommendations --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7da99cf..910d385 100644 --- a/README.md +++ b/README.md @@ -23,12 +23,12 @@ IPv6="${IPv6:-$IPv6_LOOKUP}" # use $IPv6, if set, otherwise IP_LOOKUP 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 "/dir/for/pihole/:/etc/pihole/" \ + -v "/dir/for/dnsmasq.d/:/etc/dnsmasq.d/" \ + -e ServerIP="${IP}" \ + -e ServerIPv6="${IPv6} \ --restart=always \ - diginc/pi-hole:alpine + diginc/pi-hole:latest ``` 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. From 9705a9c8cf37af66a554812971d01119d24713d4 Mon Sep 17 00:00:00 2001 From: Tom Moore Date: Wed, 24 May 2017 10:09:14 -0400 Subject: [PATCH 2/3] Fixed missing " --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 910d385..36ae7b7 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ docker run -d \ -v "/dir/for/pihole/:/etc/pihole/" \ -v "/dir/for/dnsmasq.d/:/etc/dnsmasq.d/" \ -e ServerIP="${IP}" \ - -e ServerIPv6="${IPv6} \ + -e ServerIPv6="${IPv6}" \ --restart=always \ diginc/pi-hole:latest ``` From e2879d4331b6f9807396990f11df07d0e068327c Mon Sep 17 00:00:00 2001 From: Tom Moore Date: Wed, 24 May 2017 10:16:56 -0400 Subject: [PATCH 3/3] Added systemd service file and included instructions on it's use --- README.md | 6 ++++++ pihole.service | 13 +++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 pihole.service diff --git a/README.md b/README.md index 36ae7b7..81faad0 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,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 + +If you would like to have your docker container run as a systemd service (useful for always-on servers) add the file "pihole.service" to "/etc/systemd/system". 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". You can also enable it to auto-start on boot with "systemctl enable pihole". The service file will also auto-restart the docker container if it stops, so you could remove the "--restart=always" parameter from the initial run command if needed. + +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: diff --git a/pihole.service b/pihole.service new file mode 100644 index 0000000..b4cbad7 --- /dev/null +++ b/pihole.service @@ -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 +