[SOLVED] creating container templates

inxsible

Active Member
Feb 6, 2020
139
8
38
I find myself creating a bunch of containers based on Archlinux and then installing a single service on it. Each time I create one, I have to:
  1. setup pacman mirrors
  2. update the machine
  3. install zsh and a couple other packages
  4. set up a bind to a nas export
  5. copy the vim settings and zsh settings
  6. change the login shell to zsh
  7. set up systemd timers to auto-download the updates, check mirror speeds and accordingly switch to a faster mirror
I was thinking of doing this once more -- and then creating a container template out of it. Will all of the above steps be captured in this new container template? I understand that it is quite a hassle to convert a template back into a container -- so I wanted to be sure before I did it.

Since I would have copied the zsh & vim setting and also used zsh as the login shell -- would the subsequent containers created from this template also have that immediately after creation?

Thanks,
 
a container template is just a tar(.gz) containing the rootfs. it should normally not contain anything instance specific (such as SSH host keys or other host IDs). for ArchLinux there is https://git.proxmox.com/?p=aab.git;a=summary that should handle most of the boiler plate for you.
 
a container template is just a tar(.gz) containing the rootfs. it should normally not contain anything instance specific (such as SSH host keys or other host IDs). for ArchLinux there is https://git.proxmox.com/?p=aab.git;a=summary that should handle most of the boiler plate for you.
maybe I am not getting the concept of creating a template then. I used the Archlinux template originally to get the rootfs installed, but obviously that is not enough for usage -- updates & mirrors + extra users based on services installed + changing login shell (for those that use something other than bash) etc...

I thought that these tasks could be done once and then a "personal template" could be created so that I wouldn't have to repeat the common steps when creating subsequent containers. Is this thinking flawed? If so, what is the purpose of the option "Convert to template" ?


For now though, I created a container with all the settings that I like and then I used the Clone option to recreate a similar container (same ram, hdd, cpu etc) and this worked out well enough. Once the container is created, I can start it up and add a non-root user depending on the service I plan to install in that container and then go from there. I am going to keep one of the containers as a sort of "template" and keep cloning it when I want to create a new container in order to avoid repeating the listed tasks.

thank you,
 
Last edited:
there are two types of templates for containers:
- templates created by some sort of builder, or downloaded from a APLInfo compatible server
- templates created by converting an existing container into a template container

the first kind of template is used for "creating" a container, the second kind of template is used for "cloning" a container template. you can choose whichever you prefer. in both cases you'd only create the template once, and then use it to create container instances.
 
there are two types of templates for containers:
- templates created by some sort of builder, or downloaded from a APLInfo compatible server
- templates created by converting an existing container into a template container

the first kind of template is used for "creating" a container, the second kind of template is used for "cloning" a container template. you can choose whichever you prefer. in both cases you'd only create the template once, and then use it to create container instances.
Ok. so looks like I was on the same track. What is the difference between Clone & Create a template options?

I get the difference as in cloning is cloning an actual container, but would it result in the same?

Clone an existing container (which has all the settings I want) == Create a new container instance from a previously created "personal" template
 
under the hood it works almost the same. creating from a template allows setting the config at the same time, cloning just allows selection of storage and name.
 
Hello, It is almost 3 years since this thread started but I've a further question closely related to this topic.

I've just created a "Container template" for my own use by "converting an existing container into a container template". The container template appears in the GUI with an icon that shows it IS a container template.

I can't see that container-template available outside the node were the container-template was created. I need to create new containers in that node and them move them to another node! It is a shame the container-template cannot be "uploaded" to the "CT-Templates" shared storage.

The question is:

What else shall be done, in order to create a proper "CT-Template" from a "container template"?

Thanks!
 
for containers there are two kinds of "templates"
- you can convert an existing container into a template (just like a VM), and then create clones (linked or full, linked requires storage support) from it
- .tar archives containing a stripped-down rootfs, which are used to create new containers (these are basically the equivalent of .iso files for VMs, although they just need to be extracted and not run a full installer)

both are used to create new containers in a way, but their intended use cases are different - the first one is used to clone an existing container, the latter to create a fresh one.

if you want to create a template in the latter sense from an existing container, you'd usually remove anything that's specific to that instance (network config, host name, data, ..) and then tar it up. normally they are not created from already existing containers, but boot strapped using tooling for that particular distro:
- DAB (for debian-based containers)
- AAB (for arch-based containers)
- distrobuilder (what the LXC project uses, most of our templates are generated with this)
- ...
 
@fabian

Thank you for the information!

I'm going to untar one of the downloaded CT-Templates and explore "distrobuilder" for my use case.

Regards
Ignacio
 
  • Like
Reactions: iamwillbar
I am in exact same situation as OP, I keep doing Arch containers and having to perform the same tedious steps before changing just small things at the very end unique to the indivual container itself.. I was sincerely hoping either "clone" or creating a template somehow with the click of a button inside the GUI would be possible, but I guess if I am understanding correctly, it is is not.. I am just a novice user and not sure I'd be able to correctly use 3rd party tools mentioned above so I do hope Team Proxmox considers something like this! I would pay money for this feature alone as it would be a big time saver for me
 
Last edited:
you can definitely create your own templates, both in the sense of "template that a new container is created from" (it's just a tar.gz/xz/.. with the rootfs inside without any instance-specific configuration) and "template that a copy can be cloned from" (that is a CT config + volumes with a special marker). you can even just have your container and do full clones without first converting it to a template.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!