This works as a TrueNAS SCALE App with VLAN

tl;dr - persist Channels DVR docker image on TrueNAS Scale
... by creating a dataset and adding a couple of folders within that dataset... then reference them when setting up the "Launch Docker Image"

tl;dr - keep Channels DVR docker image traffic confined to a vlan on TrueNAS Scale
... by assigning a physical interface to a vlan and then assigning the vlan to a bridge and then assigning the bridge as the network for the Channels DVR docker image


I've been successfully running Channels DVR on a Raspberry Pi 4. I recently started using TrueNAS for the NAS functionality and when SCALE came out, I thought it would be good to use the power of my NAS box to host Channels DVR and free up the Raspberry Pi for something else.

I know next to nothing about Docker, Kubernetes and Helm Charts and reading a bunch of posts across various forums was rather intimidating. But thanks to all of those posts and a bunch of trial and error on my system, I finally managed to get the channels-dvr docker image running as an App on TrueNAS SCALE. Some posts said to just bypass scale apps and use docker directly, but warned that an update to TrueNAS SCALE would break the implementation. Some of the examples I tried didn't allow me to send channels-dvr traffic over a vlan. And the simple "Launch Docker Image" scenario would not persist the channels-dvr setup (every reboot deleted everything in the channels-dvr image and required a re-setup). I also tried the TrueCharts docker_compose tutorial that included Portainer, but it wasn't clear to me where the dvr recordings were being saved so that I could explicitly back them up with snapshots and replication (it felt like the movie Inception... a container within a container within a container). In the end, what worked for me was the simple "Launch Docker Image" on the Apps page with a few changes to Networking and Storage.

Every user scenario is different. In my case, I have a TrueNAS Mini X+ from iXsystems that has two LAN ports. Port 1 (eno1) is untagged SMB share traffic for normal NAS stuff. I wanted Port 2 (eno2) to be used for vlan traffic specific to IoT devices (like iPhones, Apple TVs, and the HDHomeRun tuner) that cannot access any other datasets on the TrueNAS box. I also am 100% Unifi from Ubiquiti so my managed switches can handle the vlan traffic. Here's how I made it work on my system. YMMV.

Step 1: Create a dataset and subfolders

  • Storage -> your-pool-here -> hotdog menu (the stacked dots) -> Add Dataset
    • Name = "dockerdata" (or whatever name you prefer)
    • keep all other defaults
  • System Settings -> Shell
    cd /mnt/your-pool-here/your-docker-dataset-here
    mkdir channels
    cd channels
    mkdir config
    mkdir recordings
    

Step 2: Create a VLAN and Bridge to keep the channels-dvr traffic separate from the rest of TrueNAS. Key point being to ensure new interfaces do NOT use DHCP

  • Network -> Interfaces -> your-main-interface-here (i.e. eno1)
    • you may need to toggle DHCP (found a situation where SCALE complained that only one interface can have DHCP... even though only one did... had to turn it off, save it and turn it back on)
  • Network -> Interfaces -> your-secondary-interface-here (i.e. eno2)
    • ensure DHCP is OFF (again, you may need to toggle it)
  • Network -> Interfaces -> Add
    • type = vlan
    • name = "vlanXX" where xx is the vlan ID (i.e. "vlan50"). The name MUST start with "vlan"
    • VLAN Settings:
      • Parent Interface = your-secondary-interface-here (i.e. eno2)
      • Vlan Tag = your-vlan-id-here (i.e. 50 for vlan id 50)
  • Network -> Interfaces -> Add
    • Type = Bridge
    • Name = "brXX" where xx is the vlan ID (i.e. "br50"). The name MUST start with "br"
    • Bridge Settings:
      • Bridge Members = the-vlan-you-created-above (i.e. "vlan50")

Step 3: Add the channels-dvr docker image

  • Apps -> "Launch Docker Image" big blue button
    if this is your first visit to the Apps page, you will be prompted to select a pool, upon which SCALE will create a dataset named "ix-applications"... it may take a while
    • Application name = "channels-dvr" (call it whatever you want)
    • Image Repository = "fancybits/channels-dvr"
    • Image Tag = "tve" (I use TV Everywhere but you can use "latest" if you wish)
    • Container Environment Variables -> Add
      • Name = "TZ" ... for Time Zone
      • Value = your-locale (i.e. Americas/Seattle)
    • Networking -> Configure Add external Interfaces -> Add
      • Host Interface = the-bridge-you-created-above (i.e. "br50")
      • IPAM Type = "Use DHCP"
        • note: Every time the container is restarted, it will get a new MAC address which will likely result in a new IP address. In my case, having all Apple devices, the bonjour service still worked even though the IP was different every time. If you want to use a static IP, set IPAM Type = "Use static IP".
          • If anyone knows how to persist the mac address, please chime in (I tried both 'Container CMD' and 'Container Args' with --mac-address="XX:XX:XX:XX:XX:XX" to no avail... probably because these are kubernetes options and not docker options)
    • Storage -> Configure Host Path Volumes -> Add
      • Host Path = /mnt/your-pool-here/your-docker-dataset-here/channels/config
      • Mount Path = /channels-dvr
    • Storage -> Configure Host Path Volumes -> Add
      • Host Path = /mnt/your-pool-here/your-docker-dataset-here/channels/recordings
      • Mount Path = /shares/DVR
  • tap Next through the rest of the questions then tap Save and it will spin up the container (it takes a couple of minutes to ramp it up).

To find the IP address that was assigned to the container via DHCP, do the following:

  • Apps -> Installed Apps -> channels-dvr (or whatever you named it) -> hotdog menu -> Shell
    ip a
    

If you followed the above steps, your vlan DHCP server should have assigned an IP address to interface "net1" (kubernetes will have also assigned a different IP to "eth0" but we wont use that one).

Now use that IP to manage Channels DVR on port 8089 (i.e. http://192.168.50.15:8089). When you setup Channels DVR via that web page, select "/shares/DVR" as the place "to store DVR recordings and data", then proceed with the rest of setup as usual.

The above steps enabled my TrueNAS SCALE system to deploy Channels DVR as a docker image app that works on a vlan and survives app restarts and server reboots.