TrueNAS SCALE + Docker Compose

Out of chronicle duty and because of the fast and all the changes, I will only mention that I record the material on TrueNAS-SCALE-22.12.3.1 version current as of July 2023.

 

If anyone is interested in something like an introduction then in the material [TrueNAS SCALE + Docker + Kubernetes - how to do it ] I tell you how to install Docker on TrueNAS SCALE and why it doesn't stack on TrueNAS CORE. I also tell why exactly Kubernetes is the only right / possible choice for TrueNAS SCALE.

Docker Compose on TrueNAS - why?

Well, yes, but sometimes we need to use Docker Compose. Right? Well okay sometimes maybe we just want to but it's still a good reason.

 

Perhaps you already have TrueNAS SCALE and don't want to install a virtual machine to test something.

 

Anyway, if you would like to know more about Docker Compose itself, I invite you to the material [Docker Compose - what, why, and how? - complex applications on "click"]

 

Well, but Docker Compose and Kuberneres are ... not compatible. In a giant nutshell, they are simply different ways of managing containers.
Theoretically, on TrueNAS SCALE we could just install the Docker Compose package because after all, we just have Debian underneath. APT INSTALL ... and so on. Admittedly, we would first have to dig around to make it possible to install this way at all, because originally it is blocked for a reason. You no less so it is possible and it works. It's just that by acting in this way we are acting against the intention of the developers. And in such a situation, don't be surprised that it may not work predictably well and almost certainly won't survive TrueNAS updates.

Docker Compose on TrueNAS - an inception

As there is a need, and most often someone has had it before, and most often they have already solved it in an interesting way. In this case, the people of the TrueCharts project [https://truecharts.org/] creating a project separate from TrueNAS create ready-to-implement applications here also gave advice.

 

This solution is quite interesting but it is worth knowing something about it before using it. Because it's a bit of an inception. It is definitely intuitive, at least at first. Well, when we want to fire containers using Doekce Compose on TrueNAS, which is really on kubernetes, we need to install an application from the aforementioned TrueCharts. Seemingly nothing simpler but slowly there are hooks. In fact, the moment we install the Docker Compose application in the background using kubernetes, we are left running a container containing everything we need to run Docker Compose.

 

Only at this point can we log in to our container with Docker Compose fired up on kubernetes and fire up our application in it.

 

Well, and this is how we arrive at our inception, which is to say, we launch a container within a container.

How does it work?

Since containers by definition are stateless, that is, after a reboot, no changes will persist inside, this means that we need to mount the directories needed for our application inside. Only, we have to remember our inception. First, we need to map the directories needed for our Docker Compose container to the catalowi in our TrueNAS. Then we need a docker-compose.yml file to mount the directories of our application onto the directories of the Docker Compose container. The trouble lies, among other things, in this double mapping, because the directories we are concerned about will have a different path on TrueNAS, a different one in the Docker Compose container and a different one in our application. And believe me it is possible to get lost.

 

The second thing we need to remember to is the network. Here again there will be the proverbial baba in baba. Perhaps someone remembers such a toy.

 

So to be legal we again map the ports of our TrueNAS to the ports of the container from Docker Compose and then map the ports in Docker Compose to the ports of the container of our application. This time, however, for simplicity, we'll have our Docker Compose container connect directly to the external network and give it an IP next to our TrueNAS. To simplify things a bit.

 

 

If you would like to learn more about TrueNAS write to us. We will tell you how it works and why it is worth it?