Bobcares

Pihole Docker Ubuntu | Tutorial

by | May 29, 2022

PiHole Docker Ubuntu installation is an easy task with the experts of Bobcares by your side. 

At Bobcares, we offer solutions for every query, big and small, as a part of our Docker Hosting Support Services.

Let’s take a look at how our Docker Support Team is ready to help customers with installing and setting up PiHole Docker Ubuntu.

How to set up Pihole Docker Ubuntu

PiHole is a web application that works as a shield against unwanted advertisements. Furthermore, it blocks the internet tracking system. It is simple to use, making it a great option for homes and small office networks.

Pihole Docker Ubuntu

Today, we are going to take a look at how to set up PiHole Docker Ubuntu. One of the prerequisites involves installing Ubuntu. Then we have to update it with the latest security patches and update with the following command:

sudo apt-get update
sudo apt-get upgrade

Then we have to configure the new system with an IP address as well as a DNS name according to our environment.

The next prerequisite is installing Docker. According to our Support Techs, we can do that with the following commands:

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 add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io

After that, we have to install docker-compose with the following command:

sudo curl -L "https://github.com/docker/compose/releases/download/1.28.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Then, we have to set the permissions with this command:

sudo chmod +x /usr/local/bin/docker-compose

Next, we will configure Docker in order to run as a normal user with the following command:

sudo usermod -aG docker $USER

However, we can create a docker group if it does not already exist with this command:

sudo groupadd docker

Now, we have to stop systemd-resolve from listening on port 53 in order to successfully setup PiHole Docker Ubuntu. This involves editing the /etc/systemd/resolved.conf file in order to uncomment the line DNSStubListener. Then we have to change the setting from yes to no.

After that, restart systemd-resolved. As a result of the change we made above, the local DNS resolution will not work. We can fix this with the following commands:

sudo rm /etc/resolv.conf
sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

How to create PiHole docker-compose.yml

The next part of installing and setting up PiHole Docker Ubuntu involves creating the PiHole docker-compose.yml with these steps:

  1. First, open the terminal and start Docker.
  2. Next, enter the following command to download PiHole from the docker hub:
    sudo docker pull pihole/pihole
  3. Then, change the DNS to something else and set DNS 8.8.8.8 and save.
  4. After that, copy the following code:
    version: "3"
    
    services:
      pihole:
        container_name: pihole
        image: pihole/pihole:latest
        ports:
          - "53:53/tcp"
          - "53:53/udp"
          - "67:67/udp"
          - "8000:80/tcp"
          - "8443:443/tcp"
        environment:
          TZ: 'America/New_York'
          WEBPASSWORD: 
          VIRTUAL_HOST: :8000
        # Volumes store your data between container upgrades
        volumes:
          - './etc-pihole/:/etc/pihole/'
          - './etc-dnsmasq.d/:/etc/dnsmasq.d/'
        dns:
          - 
        # Recommended but not required (DHCP needs NET_ADMIN)
        #   https://github.com/pi-hole/docker-pi-hole#note-on-capabilities
        cap_add:
          - NET_ADMIN
        restart: unless-stopped
  5. Finally start PiHole with the following command and we are done.
    docker-compose up -d

[Need assistance with a different issue? We are available 24/7.]

Conclusion

In a nutshell, our skilled Docker Support Engineers at Bobcares took us through installing and setting up PiHole Docker Ubuntu.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

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

Never again lose customers to poor
server speed! Let us help you.