Skip to content

Instantly share code, notes, and snippets.

@diginc
Last active March 28, 2020 22:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save diginc/ced3f34d4c62df08fe1fb3055ed17382 to your computer and use it in GitHub Desktop.
Save diginc/ced3f34d4c62df08fe1fb3055ed17382 to your computer and use it in GitHub Desktop.
# SETUP DOCKER
sudo bash
docker ps
apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository "deb [arch=arm64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get install docker-ce docker-ce-cli containerd.io
sudo docker run hello-world
# SHUTDOWN SYSTEMD RESOLVER
sudo sed -r -i.orig 's/#?DNSStubListener=yes/DNSStubListener=no/g' /etc/systemd/resolved.conf
cat /etc/systemd/resolved.conf
ll /etc/resolv.conf
rm /etc/resolv.conf && ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
cat /etc/resolv.conf
ll /etc/resolv.conf
cat /run/systemd/resolve/stub-resolv.conf
sudo shutdown -r now
# GRAB RUN SCRIPT (Docker-compose pip install has cffi compile errors and I didn't feel like fixing them)
curl -O https://raw.githubusercontent.com/pi-hole/docker-pi-hole/master/docker_run.sh
chmod +x docker_run.sh
docker rm -f pihole ; ./docker_run.sh
# TEST
## Hit 100 ads
docker exec -it pihole bash
head -100 /etc/pihole/gravity.list | while read ad ; do dig $ad @127.0.0.1 >/dev/null ; done
## Hit 100 not ads
for i in `seq 1 100` ; do dig pihole.net @127.0.0.1 >/dev/null ; done
## Check stats
apt-get update
apt-get install -y telnet
telnet 127.0.0.1 4711
>stats
domains_being_blocked 127954
dns_queries_today 210
ads_blocked_today 100
ads_percentage_today 47.619049
unique_domains 105
queries_forwarded 6
queries_cached 104
clients_ever_seen 1
unique_clients 1
dns_queries_all_types 210
reply_NODATA 3
reply_NXDOMAIN 0
reply_CNAME 2
reply_IP 204
privacy_level 0
status enabled
---EOM---
root@ip-172-31-53-108:~/pihole1# docker images --digests
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE
pihole/pihole latest sha256:8c172c4cf344232a137202811b0c13a0542551076798d7635ef5368f40d1fe71 505ad79f9e8a 4 weeks ago 335MB
root@ip-172-31-53-108:~/pihole1# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bd78d23c3466 pihole/pihole:latest "/s6-init" 11 minutes ago Up 11 minutes (healthy) 0.0.0.0:53->53/tcp, 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:53->53/udp, 67/udp pihole
root@ip-172-31-53-108:~/pihole1# cat docker_run.sh
#!/bin/bash -ex
# https://github.com/pi-hole/docker-pi-hole/blob/master/README.md
docker run -d \
--name pihole \
-p 53:53/tcp -p 53:53/udp \
-p 80:80 \
-p 443:443 \
-e TZ="America/Chicago" \
-v "$(pwd)/etc-pihole/:/etc/pihole/" \
-v "$(pwd)/etc-dnsmasq.d/:/etc/dnsmasq.d/" \
--dns=127.0.0.1 --dns=1.1.1.1 \
--restart=unless-stopped \
pihole/pihole:latest
printf 'Starting up pihole container '
for i in $(seq 1 20); do
if [ "$(docker inspect -f "{{.State.Health.Status}}" pihole)" == "healthy" ] ; then
printf ' OK'
echo -e "\n$(docker logs pihole 2> /dev/null | grep 'password:') for your pi-hole: https://${IP}/admin/"
exit 0
else
sleep 3
printf '.'
fi
if [ $i -eq 20 ] ; then
echo -e "\nTimed out waiting for Pi-hole start, consult check your container logs for more info (\`docker logs pihole\`)"
exit 1
fi
done;
root@ip-172-31-53-108:~/pihole1# lshw -c cpu
*-cpu
physical id: 2
bus info: cpu@0
capabilities: fp asimd evtstrm aes pmull sha1 sha2 crc32 cpuid
root@ip-172-31-53-108:~/pihole1# uname -a
Linux ip-172-31-53-108 4.15.0-1054-aws #56-Ubuntu SMP Thu Nov 7 16:18:50 UTC 2019 aarch64 aarch64 aarch64 GNU/Linux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment