QNAP - Installation via Container Station’s API

Rather than use the UI to build your Home Assistant Docker container, you can do it all via the command line using its API.

https://qnap-dev.github.io/container-station-api/

Here’s how I did it…

  1. On any device, access it via the command line, In this situation, I’m doing it on the QNAP itself via ssh.

  2. The first thing to do is to create an authentication cookie so that can then be leveraged to send the required commands - < make sure to use an existing user account with admin privileges. > and update the IP to that of your NAS.

curl -q -XPOST -c cookies.txt -d "username=admin&password=password" http://192.168.1.111:8080/containerstation/api/v1/login
  1. With the cookie created, next identify, or create a folder on your NAS for where you want to save/store all the HA configuration files you’ll be working with. (You can do this via QFile or windows if you want - I have a share called Backups and store my VMs etc in that. )
/share/Backups/VM/homeassistant
  1. Finally enter/paste the following into the command line to create the Container.
curl -sq -XPOST -b cookies.txt -d '{ "type": "docker", "name": "home-assistant-test", "image": "homeassistant/home-assistant", "tag": "2021.1.5", "autostart": true, "environment": [ "TZ=Europe/London" ], "network": { "mode": "host" }, "resource": { "limit": { "cputime": 250, "cpuweight": 250, "memory": "2048" } }, "volume": { "host": { "/share/Backups/VM/homeassistant": { "bind": "/config", "rw": true } } } }' http://192.168.1.111:8080/containerstation/api/v1/container

IMPORTANT - make sure to check the details, and update things like the IP address above again, adjust the Time Zone (TZ) and/or the volume/storage location too ( if different.) - I’ve also assigned 25% cpu and 2Gb of memory; feel free to change that if you like, plus I’ve specified a image version number for the Docker to download- you can change this to an earlier version, or update it to “latest” to get the, errr latest …

  1. Then finally, as I used the ‘Host’ option in the build - you can simple reach the HA container via your NAS IP with the HA port of 8123
//192:168.1.111:8123
1 Like

Here’s the json part, broken out so you can see, it’s pretty straight forward.

{
   "type":"docker",
   "name":"home-assistant-test",
   "image":"homeassistant/home-assistant",
   "tag":"2021.1.5",
   "autostart":true,
   "environment":[
      "TZ=Europe/London"
   ],
   "network":{
      "mode":"host"
   },
   "resource":{
      "limit":{
         "cputime":250,
         "cpuweight":250,
         "memory":"2048"
      }
   },
   "volume":{
      "host":{
         "/share/Backups/VM/homeassistant":{
            "bind":"/config",
            "rw":true
         }
      }
   }
}