Iocage

From wikinotes

Python system to help automate and manage FreeBSD jails.

NOTE:

iocage is really need, but has a hard dependency on zfs.
This makes it difficult to test in virtualized environments like vagrant.

Documentation

official docs http://iocage.readthedocs.org/en/latest/
github https://github.com/iocage/iocage
homepage https://iocage.io/

Tutorials

Dan Langville tutorial https://dan.langille.org/2015/03/07/getting-started-with-iocage-for-jails-on-freebsd/

Install

sudo pkg install iocage
sudo iocage fetch                         # fetch current release of FreeBSD
sudo iocage fetch release="10.2-RELEASE"  # fetch a specific release of FreeBSD

Usage

Creation/Deletion

iocage fetch  # grab an image of your current release

iocage create -c   `# create lightweight (clone) jail` \
       tag=jailname                     \
       ip4_addr="em0|192.168.1.230/24"  \
       hostname="myjail"                \
       boot=on

iocage create -b          # create a new base-jail

iocage start    jailname  # start jail
iocage stop     jailname  # stop jail
iocage destroy  jailname  # delete a jail 


iocage chroot   jailname  # chroot into jail
iocage console  jailname  # access jail as if on tty(?)

Jail Management

iocage list          # list all jails
iocage set  var=val  # modify a jail's property


Start on boot

### make sure to enable iocage in rc.conf!!
iocage set boot=on      myjail
iocage set priority=20  myjail

Config

# /etc/rc.conf
# this autostarts jails on boot (provided they have been configured to start on boot)
# with the command:   `iocage set boot=on jailname`

iocage_enable="YES"