mirror of
https://github.com/pi-hole/docker-pi-hole.git
synced 2025-12-20 02:18:51 +00:00
Merge pull request #83 from mattkenn4545/feature/remove-interface-from-runs
Use ip route to determine IP
This commit is contained in:
@@ -16,8 +16,8 @@ One crucial thing to know before starting is the docker-pi-hole container needs
|
|||||||
|
|
||||||
```
|
```
|
||||||
IMAGE='diginc/pi-hole'
|
IMAGE='diginc/pi-hole'
|
||||||
NIC='eth0'
|
IP_LOOKUP="$(ip route get 8.8.8.8 | awk '{ print $NF; exit }')" # May not work for VPN / tun0
|
||||||
IP=$(ip addr show $NIC | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)
|
IP="${IP:-$IP_LOOKUP}" # use $IP, if set, otherwise IP_LOOKUP
|
||||||
docker run -p 53:53/tcp -p 53:53/udp -p 80:80 --cap-add=NET_ADMIN -e ServerIP="$IP" --name pihole -d $IMAGE
|
docker run -p 53:53/tcp -p 53:53/udp -p 80:80 --cap-add=NET_ADMIN -e ServerIP="$IP" --name pihole -d $IMAGE
|
||||||
|
|
||||||
# Recommended auto ad list updates & log rotation:
|
# Recommended auto ad list updates & log rotation:
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ docker build -f alpine.docker -t diginc/pi-hole:alpine .
|
|||||||
docker tag diginc/pi-hole:alpine diginc/pi-hole:latest
|
docker tag diginc/pi-hole:alpine diginc/pi-hole:latest
|
||||||
docker build -f debian.docker -t diginc/pi-hole:debian .
|
docker build -f debian.docker -t diginc/pi-hole:debian .
|
||||||
|
|
||||||
IP=$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)
|
IP_LOOKUP="$(ip route get 8.8.8.8 | awk '{ print $NF; exit }')" # May not work for VPN / tun0
|
||||||
|
IP="${IP:-$IP_LOOKUP}" # use $IP, if set, otherwise IP_LOOKUP
|
||||||
|
|
||||||
# Alternative ports to not conflict with my real instance
|
# Alternative ports to not conflict with my real instance
|
||||||
# shellcheck disable=SC2068
|
# shellcheck disable=SC2068
|
||||||
@@ -15,4 +16,3 @@ docker run -it --rm --cap-add=NET_ADMIN \
|
|||||||
-e VIRTUAL_HOST='pihole.diginc.lan:5080' \
|
-e VIRTUAL_HOST='pihole.diginc.lan:5080' \
|
||||||
$@ \
|
$@ \
|
||||||
diginc/pi-hole:"${image:-alpine}"
|
diginc/pi-hole:"${image:-alpine}"
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
IMAGE=${1:-'diginc/pi-hole:alpine'}
|
IMAGE=${1:-'diginc/pi-hole:alpine'}
|
||||||
NIC=${2:-'eth0'}
|
IP_LOOKUP="$(ip route get 8.8.8.8 | awk '{ print $NF; exit }')" # May not work for VPN / tun0
|
||||||
IP=$(ip addr show "$NIC" | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)
|
IP="${IP:-$IP_LOOKUP}" # use $IP, if set, otherwise IP_LOOKUP
|
||||||
|
|
||||||
# Default ports + daemonized docker container
|
# Default ports + daemonized docker container
|
||||||
docker run -p 53:53/tcp -p 53:53/udp -p 80:80 \
|
docker run -p 53:53/tcp -p 53:53/udp -p 80:80 \
|
||||||
|
|||||||
Reference in New Issue
Block a user