Is it possible to mount a dataset in a docker application?

abraham_v

Dabbler
Joined
May 15, 2021
Messages
16
I am puzzled by what a dataset is in TrueNAS nomenclature. They are created within storage pools, so it makes sense to think of them as being "under" a specific pool. I can set limits on them (eg: 1GiB), which should mean that their size can never grow beyond said limit. Via the shell interface (under "System Settings > Shell") , it is possible to navigate to the folder belonging to a dataset (folder would be, `/mnt/<pool name>/<dataset name>/` ).

Is it possible to mount a dataset folder within a docker application so that the size limit is followed? If so, how?

(eg: the docker application can keep writing to the folder, but once the size limit is reached, further writes should fail)

As it currently stands (TrueNAS-SCALE-21.04-ALPHA.1), when clicking the "Launch docker image" button, there are 2 options to mount things -

* Host Path Volumes
* Volumes

If one were to select the first option (figure below),
host_path_volumes.png

we get this interface which asks us to select a "Host Path" (you need to click the "Add" button for this to appear). This looks like a file-system view to me and feels un-connected to any datasets I might have created earlier.

On the other hand the second option,
volumes_dataset.png

very clearly says "Dataset Name". But using this does not use the dataset I created earlier.

In fact, I opened a bug report about this issue, but it got closed with a "behaves as intended" resolution. I *think* the way things were explained (on the bug report), was that the "Dataset Name" (under 6. Volumes), does not refer to any exisitng datasets, but instead creates a brand new dataset which is physically located under the default iX Systems dataset.

Even saying this out-loud to myself feels confusing, so I'll just repeat my question - is it possible to mount an existing dataset within a docker application as a folder?

And well, what is the difference between these two mounting options?

I can't find any documentation to help me either. :/

Puzzled and confused,
- Abraham V.
 

ornias

Wizard
Joined
Mar 6, 2020
Messages
1,458
Datasets are not something that is TrueNAS specific, it's a ZFS thing.

View of it as a specialtype of folder (which you can also view and browse as a folder).
Settings set for a specific dataset under storage, are global. So whatever you use the folder for needs to comply with any size limits set under "storage"

- HostPath refers to a path on the host, that includes any datasets you created under storage
- Volumes are special (somewhat hidden) datasets. The name here is (mostly) for internal use only.

It's always best to make sure you yourself know what you're doing before filing a bug report.
If you're not sure, there is a big chance that you're the fault and the software is working as intended (like happened this time).


Anyhow:
You're using an ALPHA/Nightly product that is NOT released yet.
Thats why some explainations and names aren't perfect and why there isn't documentation. Unless you want to test the software (which means: Know what you're doing under the hood and test if it works as intended) and/or able to fix issues yourself because you know how the software works, I advice against using it till (at least) BETA but preferably RELEASE.
 

abraham_v

Dabbler
Joined
May 15, 2021
Messages
16
That answers a lot. Thank you @ornias !

I hope I am not coming across as, well, rude or demanding - that is most certainly not the intent! On the contrary, I do understand what it means to use alpha products. In fact, that is one of the reasons I'm here - I tried running TrueNAS core for a few months, but freebsd jails are not my area of expertise. Oh hearing that iX systems was releasing a version of TrueNAS with first-class docker support, it felt like a perfect opportunity to try it out for home-use and, well point out things a relative newcomer would find confusing! (I do understand that any "feedback" I provide can be dismissed without explanation.)

With that explanation out of the way, I would like help to understand what purpose Volumes serve in the "launch docker image" menu. Are they a ZFS thing? Or something unique to TrueNAS?

Docker containers are ephemeral by design. Data does not persist between reboots - unless you manage it separately from the container. Assuming that we want data to persist between container reboots, mounted volumes are one way to solve the problem.

What that usually means, is if I'm managing a container on some random cloud provider like AWS or Azure, I would most certainly be interested in knowing where the data is stored physically. To bring that comparison to TrueNAS, as a user, if I'm going through the trouble to setup a docker container from scratch, I *do* want to understand where/how the data is being stored. It looks like we have 2 options,

* using a ZFS dataset (which gives us the ability to set size limits, as well as to know which pool the data will be stored in)
* special Volumes

I can't quite puzzle out what use-case the special Volumes serve.

Curious,
-Abraham V.
 

ornias

Wizard
Joined
Mar 6, 2020
Messages
1,458
Oh hearing that iX systems was releasing a version of TrueNAS with first-class docker support,
Well, it supports containers, using the docker backend. It does NOT officially support using docker directly!
(and tbh, I wouldn't call it "first class" either...)


With that explanation out of the way, I would like help to understand what purpose Volumes serve in the "launch docker image" menu. Are they a ZFS thing? Or something unique to TrueNAS?

Docker containers are ephemeral by design. Data does not persist between reboots - unless you manage it separately from the container. Assuming that we want data to persist between container reboots, mounted volumes are one way to solve the problem.
You're an end-user, so sorry if I come off rude, but it is not worth it for me to explain technicallities byond the following:
It's persistent storage managed (backups and reverts) by TrueNAS.

While the hostPath volumes are not managed by TrueNAS
Thats really all you need to know.

What that usually means, is if I'm managing a container on some random cloud provider like AWS or Azure, I would most certainly be interested in knowing where the data is stored physically. To bring that comparison to TrueNAS, as a user, if I'm going through the trouble to setup a docker container from scratch, I *do* want to understand where/how the data is being stored
If you want to understand things, it's best to first start at understanding k8s and ZFS basics. For which there are multiple resources available.
On this forum we expect you do at least to basic research yourself FIRST.
It's of no use for me to explain where things are stored, if you don't even fully understand what a dataset is.

* using a ZFS dataset (which gives us the ability to set size limits, as well as to know which pool the data will be stored in)
* special Volumes
Did you even read my previous reply at all? Because I LITERALLY explained that volumes are hidden datasets. They are just not available in the GUI, because they are... managed by TrueNAS and not by you. (though with basic ZFS knowhow you can easily set quota's on them as well)

You also selected the pool to store all container data in when you opened the Apps interface the first time.

All storage on TrueNAS is done on ZFS and is using datasets to begin with, which you would know if you didn't expect to be carried by the forums.

I can't quite puzzle out what use-case the special Volumes serve.
They are managed by TrueNAS which handles creation, deletion, upgrades, backups and reverts.
They are meant for config files that need to be reverted with an application if you revert an update.
 

abraham_v

Dabbler
Joined
May 15, 2021
Messages
16
@ornias,

Thank you! That does clear up all my questions/doubts.

Especially this,

It's persistent storage managed (backups and reverts) by TrueNAS.

They are managed by TrueNAS which handles creation, deletion, upgrades, backups and reverts.
They are meant for config files that need to be reverted with an application if you revert an update.


-Abraham V.
 

impovich

Explorer
Joined
May 12, 2021
Messages
72
@abraham_v storage in k8s is quite a huge topic, I would suggest you read the official documentation which will help you to understand the difference between hostPath and volumes.

hostPath in k8s is the same as mounts in docker where you can mount a folder or whatever you want from your filesystem, all cons and pros are described in docker and k8s docs - if you want to browse your files and keep things simple use hostPath.

 
Top