How to create and use custom dockers

Hey, new to nas stuff so sorry if obvious question.
i have a (command line) twitch bot i made in c# (with twitchlib library) and was thinking i want to run it on my truenas scale system so i made a w10 virtual machine on it but that uses a lot of ram and hdd space for a very small program so i was wondering if i remade it to work on linux but i have no clue how do i make a docker image for my program and how do i install/set it up on my truenas scale system.

tldr: how do i make a docker for my own program and then install it on truenas scale.

For stuff like this you might want to spin up a Linux VM on a sparse zvol (see: Shrink zvol of VM | TrueNAS Community) so disk usage is not as much of a concern, my largest Linux VM size is 39GiB which for many TrueNAS systems is a very small drop in a very very large bucket of storage.

If you’re familiar with linux command-line you could play around with jailmaker (Sandboxes (Jail-like Containers) | TrueNAS Documentation Hub) - though this isn’t something I’ve explored myself and I have no idea if it fits your use-case, cc @Stux who is far more knowledgeable in this area than I am.

thanks ill definetly look into that first suggestion

You can use jailmaker to spin up a pseudo Linux vm.

In your case you could definitely just make a Debian sandbox (pseudo vm), and install your bot into it. Pretty much job done.

OR you could learn docker. Base your docker image off a twitchlib image or something and dockerize your bot. Probably a good learning experience.

You can also learn docker using jailmaker/sandboxes in a Debian container as above.

And then docker compose :wink:

Point is. You should start with jailmaker.

I demonstrate jailmaker in this video:

EDIT: this is actually the Sandboxes video


Too many questions for separate matters bundled into 1 :grimacing:

I’ll help you separate them and answer accordingly

i have a (command line) twitch bot i made in c# (with twitchlib library)

so i was wondering if i remade it to work on linux but i have no clue how do i make a docker image for my program

No idea since i don’t do this. maybe someone else here can get into it. You probably should ask this on the docker forum?

I did a quick google/youtube search and found this. I’m sure you can search this yourself. This is a big ask to teach the entirety of this so not sure who has the time for that :sweat:

and how do i install/set it up on my truenas scale system.

I’ll only touch on how to setup docker on truenas. i recommend you check out Stux’s video on setting up Jailmaker. This adds the jail base to be able to then install docker into it as a jail. Then you can install your docker container. I use dockge. Though you can install docker through commandline without use of dockge or portainer.

If you want troubleshoot for the exact steps, i mentioned the process in my journal

if you don’t want to wade through that and am fine figuring everything out on your own, stick to the official guides which are quick summaries

and the video stux linked above. he has 2 videos. one for the initial setup and the other for the networking portion

Not sure what level of understanding you have in regards to docker containers. Have you ever deployed a docker container? also have you editted a docker compose to deploy a docker container? These are easy things to do once you learn them. But if you are starting from scratch, you will need to learn on your own time because there is too much to cover. I recommend starting here

Some of what is mentioned in this videos you can ignore. For example install docker itself. Because you will be following Stux’s jailmaker guide for installing docker. This is the specific setup for truenas to get that to work.

1 Like

I installed jailmaker but im now confused as to what to do next :stuck_out_tongue: how do i make a debian sandbox with it? the video you linked already has a jail made and this video of yours makes a docker jail (which i tried to do but it fails to start).

edit: reading the github page helped :smiley: or at least i believe just creating a jail without a premade configuration is what i want. now i just gotta get my bot on there.

Heh. I linked the wrong one :slight_smile:

correct :slight_smile:

make a debian (or ubuntu) jail, then follow generic debian/ubuntu instructions

i did get my bot working in the jail but the moment i exit out of the truenas shell the program stops running and i need to get back in the shell then use the command to get in the jail’s shell and then run the program.
can i somehow have it always running whether im in the shell or not?

“jlmkr list” does say that the jail is running

You know a good way to do that would be to get your bot running in a docker container :wink:

You could just run your bot with screen or tmux (which you could apt install in the jail)

But sounds like you want to set your bot up as a daemon, or a service, or a bunch of things that you can do with a raw debian/ubuntu install

thank you i got it to work with tmux and for now it can be like that. i should look into dockers at somepoint :smiley: sorry if that was a obvious solution, im still new to linux stuff.

final semi related question: can i shrink the jailmaker dataset? its currently 50gb and it really doesnt need to be that big as my puny program in that jail only uses 900mb of it