Using Templates¶
Templates can save precious time!
Set up a jail and create a template from it. All packages and preconfigured settings remain available for deployment to new jails within seconds.
Any jail can be converted between jail and template as needed. Essentially, a template is just another jail which has the property template set to yes. The difference is templates are not started by iocage.
Create a template with iocage:
- Create a jail:
# iocage create -r 11.0-RELEASE -n mytemplate
. - Configure the jail’s networking.
- Install packages and/or customize the jail as needed.
- Once finished with customization, stop the jail:
# iocage stop mytemplate
. - It is recommended to add notes to the jail, so the specific jail
customizations are easily remembered:
# iocage set notes="customized PHP,nginx jail" mytemplate
- Set the template property on:
# iocage set template=yes mytemplate
. - Find the new template with iocage list -t.
Use the created template:
Use iocage create -t to create a new jail from the new template:
# iocage create -t mytemplate -n jailfromtemplate
- Find the new jail with iocage list.
- Start the jail with
# iocage start jailfromtemplate
.
Done!
Customizing a template:
To make further customizations or just patch the template, there are two options:
- Convert the template back to a jail with iocage set template=no [UUID | NAME], then start the jail with iocage start [UUID | NAME].
- If network access is unnecessary to make the changes, use iocage chroot [UUID | NAME] [Command ...] to run the needed commands inside the template.