notes/IT/Deployment docs/Deploying pihole-docker to a brand new Debian instance.md

69 lines
2.8 KiB
Markdown
Raw Permalink Normal View History

2022-12-28 22:44:02 +00:00
#documentation #homelab
2022-12-28 22:47:09 +00:00
Official docs can be found on the [github page](https://github.com/pi-hole/docker-pi-hole) and the [home page](https://docs.pi-hole.net/)
2022-12-28 22:44:02 +00:00
## Preperation
- The system was entirely updated with `sudo apt update` and `sudo apt upgrade`.
- `docker` and `docker-compose` were installed via `apt`
- It was noted that `docker.service` was not running, with an error similar to
```
Error starting daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain DOCKER: iptables failed: iptables -t nat -N DOCKER: iptables v1.8.2 (nf_tables): CHAIN_ADD failed
```
- This was resolved by running the commands below as detailed [here](https://forums.docker.com/t/failing-to-start-dockerd-failed-to-create-nat-chain-docker/78269)
```
sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
```
## Deployment
- A `docker-compose.yml` file was created with the contents:
```
version: "3"
# More info at https://github.com/pi-hole/docker-pi-hole/ and https://docs.pi-hole.net/
services:
pihole:
2022-12-29 03:04:12 +00:00
# start on boot and when crashed
restart: unless-stopped
2022-12-28 22:44:02 +00:00
container_name: pihole
image: pihole/pihole:latest
# For DHCP it is recommended to remove these ports and instead add: network_mode: "host"
ports:
- "53:53/tcp"
- "53:53/udp"
- "67:67/udp" # Only required if you are using Pi-hole as your DHCP server
- "80:80/tcp"
environment:
TZ: 'America/Chicago'
2022-12-28 22:49:18 +00:00
# set the web dashboard to have no passwd
WEBPASSWORD: ''
2022-12-28 22:44:02 +00:00
# Volumes store your data between container upgrades
volumes:
- './etc-pihole:/etc/pihole'
- './etc-dnsmasq.d:/etc/dnsmasq.d'
# https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
cap_add:
- NET_ADMIN # Required if you are using Pi-hole as your DHCP server, else not needed
restart: unless-stopped
```
2022-12-29 03:04:12 +00:00
The time zone was updated to the correct timezone, a configuration option added to make the container start automatically, and the docker container started with (Note: If you are not using a `docker` user, you will need to add your user to the docker group. This can be done with `sudo usermod -aG docker [user]`):
2022-12-28 22:44:02 +00:00
```
docker-compose -f docker-compose.yml up -d
```
You can check the status of all docker containers with `docker ps`, and get detailed logs for the pihole container with `docker logs pihole`
Test and see if the pihole is running by changing a system's DNS server to the pihole's IP, then going to `http://[ip]/admin/` or `http://pi.hole`
## Troubleshooting
- Restart the server:
```
sudo reboot -h now
```
- Check if the container is running:
```
docker ps
```
- Check the logs:
```
docker logs pihole
```
- See if the container is listening(grep can be omitted to check all services):
```
sudo ss -tulpn | grep 53
```