Are you looking for a step by step guide to deploy Adguard Home in Docker? If so, then you’ve come to the right place. Adguard Home is a great Pihole alternative for the self-hosted users who would rather setup DNS ad blocking via a container instead of a raspberry pi.

This guide assumes you already have Docker installed and have SSH access to your Ubuntu server.


What is Adguard Home?

Adguard Home is a network-wide ad and tracker blocker. Basically, once it’s setup you will add the IP address of your Adguard Home DNS server to the IP address settings of each computer in your house, or add it as primary DNS in your router – automatically blocking ads across all devices in your home.


Adguard Home vs PiHole?

I’m not going to go into the details of whether or not Adguard Home or PiHole is better, but if you are curious, Adguard has created a comparison chart so you can make the decision yourself: https://github.com/AdguardTeam/AdGuardHome/wiki/Comparison

I’ve been using PiHole for the last 6 months or so on a raspberry pi 3 B+ without any issues at all. I’ve added PiHole to my Organizr, Heimdall, and Homer dashboards. I have no real complaints with PiHole. The only reason I’m switching to Adguard Home is because I repuposed my raspberry pi to be used with home assistant. Oh, and I also like the idea of running it in Docker instead of having to purchase another rasperry pi.


Deploy Adguard Home in Docker

To deploy Adguard Home as a docker container, simply SSH into your host and run the below command.

This docker command will automatically download the image in the specified path. It will also tell it to automatically restart unless you manually stop the container, which is very useful in case you ever restart your Docker VM.

Optional: If you have something running on port 3000 already, feel free to change it to a different port. You should also change the paths.

docker run --name adguardhome -v /srv/config/AdguardHome/workdir:/opt/adguardhome/work -v /srv/config/AdguardHome/confdir:/opt/adguardhome/conf --net=host -p 67:67/udp -p 80:80/tcp -p 443:443/tcp -p 853:853/tcp -p 3000:3000/tcp -d --restart unless-stopped adguard/adguardhome

If you ran into an error message like: Error starting userland proxy: listen udp 0.0.0.0:68: bind: addr ess already in use.” Then you probably copied the syntax from the https://hub.docker.com/r/adguard/adguardhome page. I ran into this too, but after modifying the docker run command above I was able to get things to work correctly.


Adguard Home Docker Compose file

If you’re using Portainer to create the image, you can use this:

docker run --name adguardhome \
    -v /srv/config/AdguardHome:/opt/adguardhome/work \
    -v /srv/config/AdguardHome:/opt/adguardhome/conf \
    -p 53:53/tcp -p 53:53/udp \
    -p 80:80/tcp -p 3000:3000/tcp \
    -p 67:67/udp -p 68:68/tcp -p 68:68/udp \
    -p 443:443/tcp \
    -p 853:853/tcp \
    -d adguard/adguardhome

Start Adguard Home Container

The next step is to start your Docker container.

sudo docker start adguardhome

If it starts correctly, you should see the setup running at the IP address of your Ubuntu server and on port 3000. (i.e. – 192.168.68.141:3000)

If you use Yacht or Portainer as container managers, you should now see see it running there as well.

If you’re installing AdguardHome on a Ubuntu (like I am), you will see a error message on Step 2 that looks like this:


To fix DNSStubListener Error on Ubuntu:

  1. Open Putty and SSH into your Ubuntu server.
  2. Change directory to /etc/systemd/
    1. cd /etc/systemd\
  3. Take ownership of the directory so we can edit it:
    1. sudo chmod -R 777 ./
  4. Edit Resolved.conf file. You can either use sudo nano /etc/systemd/resolved.conf from Putty or log into the Ubuntu VM itself and right-click the file. We need to uncomment the two green boxes, add a DNS entry, and change DNSStubListener to no just like the image below:
  5. Create a new directory: mkdir /etc/systemd/resolved.conf.d/. Then, navigate to the directory: cd /etc/systemd/resolved.conf.d/. And finally, create the adguard file cat >>adguardhome.conf
  6. Activate another resolv.conf file:
    1. sudo mv /etc/resolv.conf /etc/resolv.conf.backup
    2. sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
  7. Restart DNSStubListener service: systemctl reload-or-restart systemd-resolved
  8. After completing those steps, refresh the Adguard Home setup page. You should no longer see that error message on Step 2!

Complete Adguard Home Setup in WebUI

Go ahead and finish setting up Adguard Home. Now that you can get past step 2, you will need to create a username and password.

By default, it won’t show any data in your Dashboard until you add the IP address as a DNS server in your devices.

First, let’s load up a webpage that displays a ton of ads such as SocialBlade.com. Verify that you see some sidebar ads on that site. After setting either option below, you should no longer see ads!


There are two ways to setup Adguard Home on your local network:

  1. Manually added IP address to DNS settings of each device
  2. Adding IP address to your router’s DNS (affects all devices)

Option 1: Manually (per device)

Open Internet & Networking Options > Change Network Options. Right click your Ethernet adapter > Properties.

Under Internet Protocol Version 4, click Properties. Add your server’s IP address to the Primary DNS field. Then, open Command Prompt and type ipconfig /renew

Option 2: Add DNS to your Router

This section will be different for everyone. For example, I’m using a TP Link Deco M5 mesh wifi network, so I needed to open the phone > DHCP server > Add the IP address there.

After adding it to your router, all devices on your local network will automatically start using Adguard Home for DNS sinkholding and tracker blocking.


Wrapping Up

While Option 2 is by far the easiest way to block ads on all devices, you should test it on 1 device first to make sure it works.

You should also consider the “wife factor” before implementing it. For example, my wife tends to click on recommended ads from Instagram. This now causes pages to simply not load. As a workaround, you could add a secondary DNS address to your router or give your wife a static DNS.

Anyway, I hope this guide helps you get everything setup in a Docker container on a Ubuntu VM.

Similar Posts

6 Comments

  1. should the dns entry in /etc/systemd/resolved.conf be the host IP of the docker machine, or 127.0.0.1?

    1. I believe it should be 127.0.0.1. That’s what works for me

  2. Hello, I got the “WARNING: Published ports are discarded when using host network mode” message and cannot access the AdGuard Home server via the port:3000.

    Thanks.

  3. Just out of curiosity, why did you elect to use Adguard Home instead of Pi-Hole? I’m trying to decide for myself! Thanks!

    1. Thanks! Yeah that was the fix 1.5 years ago, but it may not be necessary today. Thanks for letting others know!

Leave a Reply

Your email address will not be published. Required fields are marked *