Adguard in docker

July 04, 2022

What is an Adguard?

Adguard described by authors

Free and open source, powerful network-wide ads & trackers blocking DNS server step by step.

Basically it’s an adblock but on infrastructure level.

Docker-compose

In perfect world you only need to save this to docker-compose.yml and run docker-compose up -d

---
version: "3"
services:
  adguardhome:
    image: adguard/adguardhome
    container_name: adguardhome
    environment:
      - PUID=1000
      - PGID=1000
    cap_add:
      - CAP_NET_ADMIN
    volumes:
      - /home/krzys/docker-volumes/volumes/adguardconf/:/conf
      - /home/krzys/docker-volumes/volumes/adguardwork/adguardhome_adguardwork:/work
    ports:
        # DNS
        - 53:53/tcp
        - 53:53/udp
        # HTTP
        - 80:80/tcp
        # required for setup, one time only
        - 3000:3000/tcp
    restart: unless-stopped

DNS setup

On ubuntu server DNS port: 53 was used by some systemd-resolved service so to free up port, edit file:

vim /etc/systemd/resolved.conf and set DNSStubListener=no

after edit, restart using:

sudo systemctl restart systemd-resolved.service

Also, I had to explicitly fix dhcp server address

vim /etc/netplan/00-installer-config.yaml

network:
  ethernets:
#    network interface name, check via `ip a`
    ens18:
      dhcp4: true
      nameservers:
#        dhcp server, probably your router
        addresses: [10.10.10.1]
  version: 2

Set hostname

Synchronize your hostname with name static address name declared on your router

hostnamectl set-hostname omicronpersei8.lan

On router, in my case it is mikrotik:

/ip dns static add address=192.168.1.5 name=omicronpersei8.lan

Once adguard is successfully deployed, on router set default DNS server address for your network

/ip dhcp-server network set dns-server=192.168.1.1 numbers=0

where numbers is your network ID

Set upstream dns server

Last but not least, In adguard config add your router address toUpstream DNS servers

Troubleshooting

Browse docker logs
  • journalctl -fu snap.docker.dockerd.service
Network debugging tools
  • dig 1.1.1.1
  • nslookup 192.168.1.1

2022-2024