Use ip route to determine IP

This commit is contained in:
Matthew Kennedy 2017-01-07 22:16:29 -07:00
parent 6c90bab0cf
commit 472b98894e
2 changed files with 2 additions and 4 deletions

View File

@ -3,7 +3,7 @@ docker build -f alpine.docker -t diginc/pi-hole:alpine .
docker tag diginc/pi-hole:alpine diginc/pi-hole:latest
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=$(ip route get 8.8.8.8 | awk '{ print $NF; exit }')
# Alternative ports to not conflict with my real instance
# shellcheck disable=SC2068
@ -15,4 +15,3 @@ docker run -it --rm --cap-add=NET_ADMIN \
-e VIRTUAL_HOST='pihole.diginc.lan:5080' \
$@ \
diginc/pi-hole:"${image:-alpine}"

View File

@ -1,7 +1,6 @@
#!/bin/bash
IMAGE=${1:-'diginc/pi-hole:alpine'}
NIC=${2:-'eth0'}
IP=$(ip addr show "$NIC" | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)
IP=$(ip route get 8.8.8.8 | awk '{ print $NF; exit }')
# Default ports + daemonized docker container
docker run -p 53:53/tcp -p 53:53/udp -p 80:80 \