I’ve been thinking about moving my scripts into a docker container to simplify it’s configuration and use, and possible security concerns, but as I understand Docker is a sandbox. So I’m thinking it is a sandbox, how can I use the TrueNAS API from within a sandbox? It wouldn’t be a very good sandbox if I could destroy a pool from within a docker.
While I am not looking to do that myself, I still have a difficult time understanding if I could use the API.
Here are a few of the API commands: disk.query, pool.query, disk.smart_attributes, system.info, system.general.config, and I’m certain more are coming with the 25.04 release.
That is the API question. I still need to identify what other commands I possibly could not conduct, like smartctl or nvme or nvmecontrol. At this time I don’t feel TrueNAS is full featured enough in the NVMe command area, but I do hope that changes.
In my searching for information (because I suspected someone has desired to do something like interface with the TrueNAS API from within a docker), it appears the data I found were postings on how to run/control a docker from the TrueNAS side, not from within docker.
I really don’t like asking for help until I have spent days or longer (this is longer) trying to find the answer myself. Well I need a little help, just a simple answer if it is possible. I am struggling ever since I retired for the second time, my life got significantly busier (opposite what a person would think), I wish I were back working to be honest. I’m trying to figure out how to create a docker which is kicking my rear. I have watched many videos to get an idea of what I needed to do. I may get there in a few months but before I spin my wheel for those months, I just wanted to know if I can actually use those API calls from within a Docker on TrueNAS. If the answer is yes, then I will figure out how to create a docker. I have been able to create part of a docker using docker desktop, so it’s slow movement, but movement none the less.
I think you should start by removing the docker idea as a variable because it’s just a layer of abstraction that can be added later. Its certainly possible for you to construct a docker container to do this, I just don’t think you’re at that stage.
What you should probably focus on first is getting an external Linux box talking to the TrueNAS using the API.
Using midclt externally shouldn’t be much different than using midclt locally. With the obvious exception of having to authenticate.
For this bit, you could theoretically have a function in whatever script ssh over to the TrueNAS and run these types of commands as you would normally.
Thanks @NickF1227 for the advice and the positive sign that I should be able to run those API commands remotely. I will read the linked information. If I can convince myself that is all is possible, I can get behind it with much more enthusiasm.
I don’t recommend running large numbers of commands via midclt remotely. You should use a persistent session to run the full series. every command will perform separate authentication and you’ll blow up the auth log (which won’t make users very happy).
I’ve linked our api_client repo examples dir. Let me know if you think there are other examples needed.