r/truenas•
Tetrarc

"Best" way to use docker images in TrueNAS Scale these days?

SCALE

Is there a consensus best way to deploy and use docker containers in Scale? Or a place I can read about the differences and advantages of each method?

I see the following options:

  • Launch Docker Image
  • TrueCharts docker-compose
  • TrueCharts Portainer (assuming the portainer app also establishes the area for installation of other apps. Disregard if that is not true).

​

As a separate question, I see the app installation pane broken into steps when looking at tutorial videos on YouTube. My pane is just one long list of options, no defined sections. Is that something I need to enable?

​

Thanks for any help.

Posted Aug 9, 2023, 6:38 PM UTC

110
ElectraFish•

I think the consensus is that docker support in SCALE is not very good. I have, however, had really good experience running VMs. I would run a VM and then install docker instances there, perhaps with Portainer on top if you like it for docker management.

BUT, I'm not a docker person, and haven't tried any of the methods you listed. Opinions may vary.

1
TetrarcOP•

Seems to be the case - I wanted to deploy Caddy on Docker since there is a lot of praise for its simplicity and no official Chart from what I can tell. Now just to decide between VM Caddy or to learn Traefik. Thanks for the help.

1

Since scale uses k3s and Helmcharts and only uses docker as the Container runtime i'd say the best way to run native docker is a vm, especially since the upstream k3s Change from docker to Containerd will be implemented with the next big Update called Cobia this year. With that Update docker will be completely removed from the Base OS. Even the big blue launch docker Button created a Helm Charts in the Background.

1
TetrarcOP•

Good to know. Is this going to affect TrueCharts ability to use Docker Compose (if you know)? I imagine so.

1
UnderEu•

Do VMs

1
dn512215•

I got fed up and added a VM with Portainer. Never looked back.

1
LightBroom•

Learn a bit of Kubernetes and use Helm charts.

1
RedKomrad•

How would you use a custom (user made) helm chart with TN after you make one?

1
LightBroom•

Either from the command line by running Helm directly or with GitOps, where you create your resources in a Git repository and something like Flux (my favourite) or ArgoCD applies them for you automatically.

GitOps is a bit more complicated for people who don't know Kubernetes at all, so there's a learning curve involved but once you get the hang of it, it works great.

You could even create charts with support for the built in iX interface, so you can see them in the Apps section. I've done this for myself and it doesn't have to have a million options, just the basics.

I just keep storage to NFS, use Emissary instead of Traefik, use one single wildcard cert for all my hosts which I replicate with kubernetes-replicator to all my app namespaces. etc.

1
RedKomrad•

I know all of that, but I was look for something practical, like a helm chart template file I can edit and then a command I can run to "install" the helm chart that I created.

I recently downscaled from a Proxmox cluster that was running my k3s cluster, and I'm looking to downscale more by shutting down a VPN I have running apps on. However, there is one app that uses multiple containers that I can't just create a custom TrueNAS app for.

So, I'd deciding between making a custom helm chart for it (potentially the simplest path ) , or standing up a VM to move the docker compose "stack" to. My goal is to make things as simple and easy to maintain as possible.

Quite the opposite of what I was doing before!

1
LightBroom•

Well.

"helm create <chartname>" will create a basic template for you. Add the resources you need, tweak it until you're happy with and the you're set. Use it for all your stuff.

You can also have a common template that you include in your other charts, if you find you have stuff you copy/paste all the time. It's very common to have a common lib.

Then you use "helm install" or "helm upgrade --install" to install it.

Or, if you want that to happen automatically you need a pipeline you can build around Gitlab, Github, etc which every time you commit to a git repo will build the chart for you, test and publish. Then Gitops can deploy it automatically if you wish.

You can simulate that pipeline on your own machine if you wish, with a task runner (like make, or ninja, or moon). Just write tasks to build, test, push to a repo, deploy, etc so it's easy and fast while you write code.

You'll have to learn these things. I can't write a tutorial in a Reddit comment, sorry, there's a million ways to do these things and what I like some people hate, so please find the way that works for you.

1
brahmy•

This comment 3 months ago was my inspiration to get off TrueNAS Apps (I had already ditched TrueCharts a while ago due to multiple breaking changes). About a month ago I set up a Ubuntu 22.04 VM running vanilla Docker and it's been great.

There are some great details in the thread I linked, here are some additional tips I learned along the way...

  • Do a bridge network so any remaining TN Apps can talk to the VM apps and vice versa.
  • If you go with Ubuntu, the Server and Desktop version are (for all intents and purposes) the same (or can be made the same), so I started with Desktop to have a GUI if needed, as I'm not a power user.
  • Ensure common users & groups exist between TN and the VM for NFS permissions and ease of sharing / mounting datasets.
  • If you're doing USB or PCI passthrough for Plex, Jellyfin, Frigate etc., ensure the "CPU mode" of the VM is not "Custom/Blank", it should be Host Model or Host Passthrough. Otherwise strange bugs may abound.
  • Suggest documenting the steps to build the VM and what software you install. I see my Ubuntu VM on TN as a jumping-off point going from a single homelab server to more than one. In the future I want to be able to easily replicate this VM to a new host or bare metal. Also helpful for troubleshooting if you get stuck during setup.
  • Set up Docker, then Portainer in Docker, then do everything else in Portainer. Portainer Stacks = Docker-Compose. This is so much better than how apps are managed in TN. Text files you can save and easily edit instead of the fly-open half-page GUI on TN.
  • Migrating from TN SCALE apps to something else is a good opportunity to clean up application configuration data. I wish I had created individual datasets for each Docker image I was going to run so I could so separate snapshots. A project for another day now!

I have 19 Docker containers running smoothly in Ubuntu now. "What's Up Docker" is a good one for keeping track of updates (and optionally, applying them) as Portainer Community Edition makes this opaque. Dozzle is another good one for making logs from multiple containers easily accessible.

I run the official TN Plex and an instance of Telegraf on TrueNAS and that's it.

1
TetrarcOP•

So I've been slowly working on a VM instead of the TrueCharts and I had a question.

I see you still use Plex as a TN app rather than in a VM - is that a performance consideration? Or you didn't want to go through the trouble of re-doing PMS?

1
brahmy•

Mostly it was an "if it ain't broke..." decision. If the Cobia updates break the official Plex app, I'll move it over to the VM too.

1
uncmnsense•

thanks for the shout out!

1
TetrarcOP•

I see your comment was the basis for his post. If you don't mind, could you share your thoughts on how you decided to keep emby (Plex in my case) in TN rather than VM bare metal or in Docker? Is it a performance concern?

1
uncmnsense•

for me the issue is gpu transcode. anyone streaming media at some point will prob have to contend with transcode of some kind. i bought an nvidia p400 for like $50 just for this purpose.

the issue is how to get the card visible by the media server. in truenas, if u isolate the card and pass it to the VM, the next step is getting it through docker and into the container. this seems like a lot of steps.

<<caveat - in the next update of truenas in oct, truenas will let more than one thing use the gpu at the same time. currently this is not possible, making life hard>>

if u run emby/plex through the truenas catalog, its soooo simple to pass the card through. literally 1 click. so i stick with that.

some notes since i made this comment: ix-systems has released a new train called the "community train". its the best train in my opinion right now. if i run any apps from the catalog, i use the blue "community" apps now, NOT the truecharts one.

many ppl have been asking me about using a VM + docker to do the *arr stack. i made this to help out those people. so much easier than doing it by hand - its now my preferred method of deployment.

1
xbgt1•

Yes, the community apps make truecharts basically unneeded now for me.

I never understood why this wasn't the case before. If you look at unraid their community apps are amazing and I put this close to on par with it now.

1
TetrarcOP•

Makes sense, I had a feeling it had to do with GPU passthrough.

For new apps available in both Docker and TN / TC will you still be favoring Docker? Or is the Community train enough to have you switch to TN apps?

1
KarmaPoliceT2•

Just curious, how do you handle hardware allocation toward that VM? did you just throw most of the system's hardware at the VM? or do you leave most of the hardware for the underlying truenas storage instance?

This has been my hangup in running a VM + Docker... I don't really know how I would want to balance cpu/mem allocation between the vm/containers and the host truenas... I certainly don't want to starve truenas of memory that could be part of its ARC, but I also want to run some pretty beefy workloads in some docker containers... to this end I kind of like how truenas' native apps allow for the hardware flexibility there... but maybe i'm just not thinking of it the right way.

1
brahmy•

I'd like to say I have an intelligent answer for you but the reality is that I built a way more powerful TrueNAS server than I needed, then set VM specs conservatively, knowing that even conservative specs would do more than I needed.

Plex is my only app running on TrueNAS so it can have all the CPU it needs, when it needs it. I have frigate running in Docker but have a dedicated GPU and Coral passed to it.

The nice thing is that VM specs are easy to change if you don't get it right on the first try.

screenshots

1
SuperQue•

I've been just writing my own Kubernetes deployments with Tanka. Use the heavyscript tool to open the K8s api and setup remote access.

You can either use Tanka, Helm, or just simple Kubernetes objects.

For example, you can kubectl apply this to get a simple service up and running. It's not much more complicated than docker-compose.

---
apiVersion: v1
kind: Namespace
metadata:
  name: my-container
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-container
  namespace: my-container
spec:
  minReadySeconds: 10
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      name: my-container
  template:
    metadata:
      labels:
        name: my-container
    spec:
      containers:
      - image: docker.io/me/my-container:latest
        imagePullPolicy: IfNotPresent
        name: my-container
        ports:
        - containerPort: 8080
          name: http
---
apiVersion: v1
kind: Service
metadata:
  labels:
    name: my-container
  name: my-container
  namespace: my-container
spec:
  ports:
  - name: my-container-http
    port: 12345
    targetPort: 8080
  selector:
    name: my-container
1
RedKomrad•

TrueNAS Cobia had been released! Time to dig in. :)

1