Qnap Docker Tutorial
Docker Daemon, an important component designed to run in the background, manages those containers using the Docker Remote API. To install Docker Daemon as a Windows Service: If necessary, download and install Docker for Windows. We have installed Docker Toolbox for this tutorial but all you need is the Docker executable. Introduction QNAP Container Station exclusively integrates LXC (Linux Container) and Docker® lightweight virtualization technologies, allowing you to operate multiple isolated Linux® systems on a QNAP NAS as well as download thousands of apps from all over the world. Creating container; Updating image; Basic Docker Usage. The name of the Docker image is lloesche/valheim-server. Volume mount the server config directory to /config within the Docker container. If you have an existing world on a Windows system you can copy it from e.g. C: Users Lukas AppData LocalLow IronGate Valheim worlds to e.g.
This blog discusses implementing a Pi-Hole ad-blocker as a virtual container application and the advantages of a container over a virtual machine.When configuring Pi-Hole v4.x on QNAP Docker, you will want to use the 'pihole/pihole:latest' container from the Docker hub. The 'diginc/pi-hole' container is based on Pihole v3.x and has been deprecated.
When I copied and pasted the url in the browser of computer I was using to remote desktop in BI machine the url would work. But if pasted in browser of the BI machine I would get Authorization Required. I found I had to add the BI machine to Limit access to IP addresses (not.
The critical steps to installing the v4.x pihole container are to go into the advanced settings and set the network to the bridged setting and set the Docker instance for Pi-Hole to run at a unique static IP address on your LAN. The other important step is to set the environment variable 'ServerIP' in the advanced settings to be the address of your Pi-Hole.This configuration will initially configure and run perfectly until you either shutdown the container or restart the QNAP NAS. Upon restart of the container, the console will indicate that there is no DNS Resolver available. The community documented solution has been to edit /etc/resolv.conf of the QNAP to point to 1.1.1.1 (Cloudflare DNS) rather than to the router. This seems to work inconsistently and is not a final solution. Other suggestions online involve stopping the DNSMASQ daemon. There is a better way.
Docker containers are preconfigured builds that use a high level API written in the 'Go' language that utilize Linux Containers (LXC). A Docker container does not include either hardware virtualization like a virtual machine (VM) or a separate operating system. A Docker instance relies upon the underlying host operating system's own functional infrastructure. Docker's advantage is that it acts as a portable container engine which packages a given application in its installed form with all of its dependencies that can run in a virtual container on any Linux server.
Both Docker and LXC are containers that present Virtual Environments (VE) on a single host. VE's do not have a preloaded emulation or hypervisor level that has to emulate a 'hardware' as in a VM. So, in general, all VE's use far less resources than a VM and you can run lots of them.
LXC containers are not just an application instance. LXC containers provide an isolated OS instance on which you can install one or more applications unlike a Docker instance which is for a single packaged installation.
Normally a container system is installed on a Linux computer, but there are Docker and LXC container systems that will run on Windows. Just keep in mind that the actual containers are Linux. Network Attached Storage (NAS) systems like QNAP and Synology normally provide a container management system to create and run Docker and LXC containers and this is natural because they are Linux hosts.
Container Station on the QNAP NAS allows the creation of Docker containers from templates on the Docker hub or you can create your own. One powerful feature of Docker containers is that you can export them and import them easily on another Docker system. The limitation to Docker containers is that once you create one, it really can't be modified. So, in the case of 'Pi-Hole', you would have to create a new container when a new version of Pi-Hole is released. That's because the Docker Image is an image.
Since LXC provides a container instance of an OS, it is possible to install one or more applications to an LXC container after creating it.
In order to provide an easier installation for pihole without the issues documented at beginning of this blog, we will use an LXC container.
On the QNAP, go into the 'Container Station'. Select the create option from the left side of the menu and then scroll to the bottom of the window. There are several types of Docker and LXC containers listed.
Choose the LXC Ubuntu 16.04 container. That's the underlying OS for the QNAP QTS Operating System on the NAS. Let's name the container 'Pi-Hole' and set the CPU limit to 20% and the memory limit to 1024MB which is more than enough for Pi-Hole.
Then click on 'Advanced Settings'. Change the network mode to 'Bridge', select 'Use Static IP' and change the IP address to a unique address on your LAN. Go back to the 'Overview' section in Container Station and after a few minutes you should see your container listed.
Click on the name of the container and you will enter the console.
Type passwd to change the password. Note the original password is ubuntu.
Before we can install Pi-hole, we need to update this very lightweight LXC container to add some features. First run updates:
sudo apt-get update
Next install the ssh server:
sudo apt-get install -y openssh-server
Now add a username other than the default. Just go through the dialogue and answer the prompts for the new user.
sudo adduser piuser
Now grant the new user privilege:
sudo usermod -aG sudo piuser
Open a terminal back on your desktop computer and 'ssh' to the new machine with the address you used to create the LXC instance:
ssh piuser@172.16.1.5
Get privilege in the command window:
sudo su
Install 'curl':
sudo apt-get install curl
Now you can install pi-hole:
curl -sSL https://install.pi-hole.net | bash
Select the defaults until the DNS screen and then choose Cloudflare as your DNS when you see the screen below.
Accept all the rest of the defaults and be careful not to change them. This will assure that you get the admin web interface and that statistics are logged. The installation will continue for a few minutes after you answer the prompts. After your installation completes, you will receive a message telling you to set up the DHCP settings on your router to make the address of your Pi-Hole the primary DNS for your network. That will insert the Pi-Hole as the 'man-in-the-middle' to scrutinize all DNS names before they are either passed to the Internet or 'Pi-Holed'.
When you return to the prompt in the 'ssh' terminal session, enter the following command to set your Pi-hole password:
pihole -a -p
You can now close the 'ssh' terminal session.
Go to your web browser and enter the address of your Pi-Hole followed by /admin:
http://172.16.1.5/admin
Select the login and you should be able to log in with the password you just set.
Since this is a 'scratch' install in an LXC container, you will be able to start and stop the container and reboot the QNAP NAS without any problems and even upgrade Pi-Hole when new releases are available. This LXC container is very lean and uses a minimal amount of system resources.
Don't forget to set the DNS settings for your DHCP server on your router because Pi-Hole will not be used by any of your network clients until that occurs. A good practice is to make the Pi-Hole DNS 1 and then Cloudflare 1.1.1.1 as DNS 2. That will assure DNS translation when your Pi-Hole is not running.
Setup HomeAssistant on QNAP Container using Docker
Lets begin by making the Home Assistant installation, find it on QNAP Container Station. Go to the ‘Create’ menu, search ‘homeassistant’ in the search bar, make sure you select the ‘Docker Hub’ tab as the ‘Recommended’ tab will shows an out of date version. You should see homeassistant/home-assistant click on ‘Install’ or ‘Create’.
I recommend that you manually select the highest version, ‘latest’ will choose the version you have currently installed as ‘latest’. This would help avoid getting confused, when you wish to update HomeAssistant, the latest at the moment is 0.112.4.
Add a new “TZ” environment to set your TimeZone, check out the List of tz database time zones
Set a static volume for the container to use, I just use QNAP “New Volume” directory. You can make your own volume using “Volume from host”, though I find permissions being a problem on some docker. For this example I shall make a folder ‘homeassistant-config’ that will point to the docker ‘/config’ folder.
Remember to expose the container 8123 port to any host port, can set it as 8123 if you wish.
You should have the basic installation ready at [I.P Address]:[Port].
You now have HomeAssistant running.
Add QNAP Sensor
What do HomeAssistant do for you and your QNAP? You can have it to monitor multiple QNAP all in one place, let me show you how.
You need to create a homeassistant account that is admin, it doesn’t need any other access but just being admin. So you can deny all “Application Privileged” and “Shared Folder Permissions”. This account will be used for HomeAssistant to login and check the status of the device.
Go to FileStation and get to the homeassistant-config volume, it is located in a nested directory.
We need to add the user details for HomeAssistant, it is best to put these details in the ‘secrets.yaml’.
Create a new yaml file called sensors.yaml, easier to just copy and paste any yaml file and rename it. The sensors file is used to provide any sensor device for HomeAssistant to monitor, for example we want to use the QNAP integration sensor. https://www.home-assistant.io/integrations/qnap/
For good practices do not put your configurations such as username and password outside of the secret file, otherwise it can be read in plain text. HomeAssistant will know that ‘!secret” means to get the config parameter from the secrets.yaml file. You can use ‘#’ to comment out unneeded things to monitor.
Edit the configuration file to include the sensors.yaml file for sensor.
Restart HomeAssistant, either through HomeAssistant by Configuration>Server Control>Restart or just restart the container.
You should see all the sensors available for your QNAP
You can make the interface much better by ‘Configure UI’
It will warn you that HomeAssistant will manage the layout for you, just press ‘Take Control’
First step add ‘Gauge’ card.
Qnap Nextcloud Docker Tutorial
You will be able to select which ever entity of the sensor to display as a gauge, RAM and Volumes are great to be displayed as gauges but it’s personal preference.
How about displaying CPU temperature, we can just use a sensor card.
This will display the temperature in a simple layout.
I prefer to have a line graph for extra details.
Now that you understand how to add basic cards on the screen, the cards seems to waste alot of space for one card. There is the horizontal stack that you can used to group these cards.
Due to the complexity of this card, you have to manually add the config yourself.
For example to show the System Temp, CPU Temp and CPU load you add this:
If you want to go crazy you can use ‘Picture Elements’ to have image background with entity on top. Here’s example how I set up my QNAP switch summary cards.
Save this image, and put them in the ‘homeassistant-config’ folder, and then you make ‘www’ folder and then an ‘images’ folder
Make a ‘Horizontal Stack’ card in manual, here is a conditional element to check if the entity exist before displaying. Useful in prevent empty bays being displayed.
You would need to restart HomeAssistant for it to see the new ‘www/images/’ folder. Once done you get this.
Additional custom cards in another post:
Qnap Docker Tutorial Software
8 Responses
Qnap Docker Tutorial App
Hi!,
My qnap server is running in http://192.168.0.166:8082/cgi-bin/. Home assistant is running on a dock. I can access it with http://192.168.0.166:8123/
I configure:
But in my HA log:
Any idea??
Thanks!
Hi,
first thank you for making this installation very simple with clear explanation !
just like to understand if it’s not an issue to get the HA version without the supervisor in the long run? (I’m new to HA but I noticed the qnap docker is only the core version)
Very nice this guide.
Tested with TS-251A, no errors, but no “sensors.” created.
Is it possible to do something?Great tutorial, thank you!
After the installation it didn’t discover any devices. I changed the network settings (and the port number) and now it works.
See here: https://community.home-assistant.io/t/integrations-not-automatically/283680/3?u=stenci
Why are you suggesting NAT rather than Host?