Docker Home-Server

Return to Projects
Note: You can copy any table entry or code snippet by clicking on it.

Table of Contents

Raspberry PI Setup

The first thing to do is setup your Raspberry PI. For that it is enough to use a firmware version without a desktop installed since it will not be used anyway. It is also advised to setup connecting to the PI using ssh.

After the initial setup connect to the PI using ssh and run the following commands to get all updates done first:


        sudo apt update
        sudo apt upgrade
      

Initial updates

Install Docker

Now that we are setup we can install docker onto the PI using:


        curl -sSL https://get.docker.com | sh
        sudo usermod -aG docker pi
      

Install Docker

The commands should have added the pi user to the group docker. To verify this we have to re-connect to the ssh session and then check the users groups using:


        exit
        
        ssh pi@your-ip
        groups
      

Verify Docker Group

The output of the groups command look a little bit like this with the docker group being present:

Simon Obermeier

Groups after Installing Docker

Portainer Installation

Now we can add portainer to the installation. This will be the user-friendly GUI from which we interact with out containers. To install this simply run the following commands:


        docker volume create portainer_data
        docker run -d -p 8000:8000 -p 9443:9443 --name portainer \
        --restart=always -v /var/run/docker.sock:/var/run/docker.sock \
        -v portainer_data:/data portainer/portainer-ce:latest
      

Install Portainer

After the command is done you can access the portainer interface using your webbrowser at http://your-ip:9443. Just ignore the SSL warning, since Portainer is using a self-signed certificate. On the first login you will be prompted to create login credetials. These will be needed everytime you want to acess the page. For the enviroments the default one is comepletely fine.

Add Containers

Upon opening the website you will be taken to the enviroments tab. There you can select local. Now you can select Containers on the left side. Here you can see all the currently installed containers and also their status.

To add a new container click on Add Container on the right side. Here you can input all the information for the new container. Some default settings for all containers are:

Useful default settings for containers

SettingAreaSet to
Always pull the imageTopTrue
Access controlTopFalse
Restart PolicyAdvanced -> Restart PolicyUnless stopped

Pi-Hole

The first container we will install is a simple Ad-Blocker called Pi-Hole.

Pi-Hole Pre-Requirements

To get the container to work correctly we first have to do some pre-requirements. First we will create all the needed directories. Just enter following commands in the terminal:


        mkdir -p /home/pi/data/pi-hole/dnsmasq
        mkdir -p /home/pi/data/pi-hole/etc
        touch /home/pi/data/pi-hole/etc/resolv.conf
        echo $'search fritz.box\nnameserver 127.0.0.1' > /home/pi/data/pi-hole/etc/resolv.conf
      

Create directories for Pi-Hole and add resolv.conf

Please swap the fritz.box entry with the IP address of your router.

Pi-Hole Installation

The Installation itself is pretty straight forwards thanks to portainer. We now just add a new container and apply the mentioned default settings like shown here. Afterwards just apply the following settings:

Pi-Hole Settings

SettingAreaSet to
NameTopPi-Hole
ImageToppihole/pihole:latest
hostnameAdvanced -> Networkpi-hole

Next are the ports which we need to open. These are on the top portion of the page under the name Manual network port publishing.

Pi-Hole Ports

Port HostPort ContainerProtocol
443443tcp
47114711tcp
5353tcp
8080tcp
5353udp
547547udp
6767udp

The next part is to setup some enviroment variables. These can be found under Advanced -> Env. Please replace the TZ variable with your timezone. Also choose your own WEBPASSWORD. This will be used the acess the web interface.

Pi-Hole Ports

NameValue
TZEurope/Berlin
WEBPASSWORDyour-password

The last part are the paths which will be linked from inside the container to the outside. These are found under Advanced -> Volumes. Please also always change the mapping mode from Volume to Bind.

Pi-Hole Paths

ContainerHost
/etc/dnsmasq.d/home/pi/data/pi-hole/dnsmasq
/etc/pihole/home/pi/data/pi-hole
/etc/resolv.conf/home/pi/data/pi-hole/etc/resolv.conf

The setup is now finished and we can press on Deploy the container at the bottom of the basic settings. Please be patient and do not click away since the docker image has to be pulled from the internet from the internet. After everything is finished the page will automatically reload and take you to your containers.

Home-Assist

Home-Assist Pre-Requirements

To get the container to work correctly we first have to do some pre-requirements. First we will create all the needed directories. Just enter following commands in the terminal:


        mkdir -p /home/pi/data/home-assist/config
      

Create directories for Home-Assist

Home-Assist Installation

We now just add a new container and apply the mentioned default settings like shown here. Afterwards just apply the following settings:

Home-Assist Settings

SettingAreaSet to
NameTopHome-Assist
ImageTophomeassistant/home-assistant:latest
NetworkAdvanced -> Networkhost

The next part is to setup some enviroment variables. These can be found under Advanced -> Env. Please replace the TZ variable with your timezone. Also choose your own WEBPASSWORD. This will be used the acess the web interface.

Home-Assist Ports

NameValue
TZEurope/Berlin

The last part is a single path which will be linked from inside the container to the outside. These are found under Advanced -> Volumes. Please also always change the mapping mode from Volume to Bind.

Home-Assist Paths

ContainerHost
/config/home/pi/data/home-assist/config

The setup is now finished and we can press on Deploy the container at the bottom of the basic settings. Please be patient and do not click away since the docker image has to be pulled from the internet from the internet. This image especially will take a long time since it is very large. After everything is finished the page will automatically reload and take you to your containers.