Skip to content

Commit

Permalink
Increase verbosity of error message when capabilities cannot be set -…
Browse files Browse the repository at this point in the history
… add note to readme about default DNSMASQ_USER. See #963 for details (#964)

Signed-off-by: Adam Warner <me@adamwarner.co.uk>
  • Loading branch information
PromoFaux committed Jan 4, 2022
1 parent 2a7ea09 commit 2c6bc33
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,30 @@ services:
ports:
- "53:53/tcp"
- "53:53/udp"
- "67:67/udp"
- "67:67/udp" # Only required if you are using Pi-hole as your DHCP server
- "80:80/tcp"
environment:
TZ: 'America/Chicago'
# WEBPASSWORD: 'set a secure password here or it will be random'
# Volumes store your data between container upgrades
volumes:
- './etc-pihole:/etc/pihole'
- './etc-dnsmasq.d:/etc/dnsmasq.d'
# Recommended but not required (DHCP needs NET_ADMIN)
- './etc-dnsmasq.d:/etc/dnsmasq.d'
# https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
cap_add:
- NET_ADMIN
- NET_ADMIN # Recommended but not required (DHCP needs NET_ADMIN)
restart: unless-stopped
```
2. Run `docker-compose up -d` to build and start pi-hole
3. Use the Pi-hole web UI to change the DNS settings *Interface listening behavior* to "Listen on all interfaces, permit all origins", if using Docker's default `bridge` network setting

[Here is an equivalent docker run script](https://github.com/pi-hole/docker-pi-hole/blob/master/docker_run.sh).

## Upgrade Notes
In `2022.01` and later, the default `DNSMASQ_USER` has been changed to `pihole`, however this may cause issues on some systems such as Synology, see Issue [#963](https://github.com/pi-hole/docker-pi-hole/issues/963) for more information.

If the container wont start due to issues setting capabilities, set `DNSMASQ_USER` to `root` in your environment.

## Overview

A [Docker](https://www.docker.com/what-docker) project to make a lightweight x86 and ARM container with [Pi-hole](https://pi-hole.net) functionality.
Expand Down
7 changes: 4 additions & 3 deletions bash_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
. /opt/pihole/webpage.sh

fix_capabilities() {
setcap CAP_NET_BIND_SERVICE,CAP_NET_RAW,CAP_NET_ADMIN,CAP_SYS_NICE,CAP_CHOWN,CAP_IPC_LOCK+ei $(which pihole-FTL) || ret=$?
setcap CAP_NET_BIND_SERVICE,CAP_NET_RAW,CAP_NET_ADMIN,CAP_SYS_NICE,CAP_CHOWN+ei $(which pihole-FTL) || ret=$?

if [[ $ret -ne 0 && "${DNSMASQ_USER:-root}" != "root" ]]; then
echo "ERROR: Failed to set capabilities for pihole-FTL. Cannot run as non-root."
if [[ $ret -ne 0 && "${DNSMASQ_USER:-pihole}" != "root" ]]; then
echo "ERROR: Unable to set capabilities for pihole-FTL. Cannot run as non-root."
echo " If you are seeing this error, please set the environment variable DNSMASQ_USER=root"
exit 1
fi
}
Expand Down

0 comments on commit 2c6bc33

Please sign in to comment.