If there is a jail you need to migrate from an existing iocage host to a new host, following these steps should help speed up the process.

I moved a jail from one host in a datacentre to another without an issue :)

A few notes:
"Storage" was the name of my zfs dataset pool used for iocage. Check your dataset name and go through the iocage directories etc.

This was done using FreeBSD 10.2 with an older version of iocage. version 0.9.3. I haven't tested it out with the newer python written version but for the most part this should still be the same. If there are any differences, I will updated this post as necessary

9a67xx was the UUID of the jail, just replace this with your UUID as you follow along. My hostname was jenkins01.ops.example.net

Lets Begin
  • Take a snapshot of your existing jail: (use the @name) to name your snapshot e.g. @jenkins here, with the hostname:
11:30:30 [email protected] ~ $ zfs snapshot -r storage/iocage/jails/[email protected]
  • Use the zfs send command to copy the snapshot into an archive before copying it over the network (I had a jumpbox in this case)
11:31:51 [email protected] ~ $ zfs send -R storage/iocage/jails/[email protected] | gzip > jenkins-9a67aab1-63c1-11e6-8bf5-286ed488c6b0.gz
  • Once you've got the gzip archive on the host you would like to import the jail to, find the dataset your iocage instance is running on, then use the full path to the jails directory in order to do the import, keeping the UUID the same. Match the directory structure of iocage (important!)

  • Uncompress the archive and do a zfs receive using the following command.

11:53:45 [email protected] ~ $ gzcat jenkins-9a67aab1-63c1-11e6-8bf5-286ed488c6b0.gz  |  zfs receive -vF cagepool/iocage/jails/9a67aab1-63c1-11e6-8bf5-286ed488c6b0

  • If you do an iocage list at this point, you should see your jail in the list:
11:58:25 [email protected] ~ $ iocage list
JID   UUID                                  BOOT  STATE  TAG                   IP
1     9a67aab1-63c1-11e6-8bf5-286ed488c6b0  on    down     jenkins.ops.example.net
-     d23b2dae-d62f-11e6-ad63-00155d010234  off   down   test_jail

Don't start it yet. Finish off the import using the following:

  • Set the host id of the jail to your current host:
12:00:00 [email protected] ~ $  iocage get hostid default
12:00:10 [email protected] ~ $
12:00:10 [email protected] ~ $
12:00:10 [email protected] ~ $ iocage set hostid=9352a7f8-1e1f-244b-9406-a099523a49a7  jenkins01.ops.example.net

You should now be able to start your jail successfully:

12:05:24 [email protected] ~ $ iocage start jenkins01.ops.example.net
* Starting 9a67aab1-63c1-11e6-8bf5-286ed488c6b0 (jenkins01.ops.example.net)
  + Started (shared IP mode) OK
  + Starting services        OK
12:05:34 [email protected] ~ $

Then console into it for good measure:

12:06:16 [email protected] ~ $ iocage console jenkins01.ops.example.net
Last login: Tue Aug 23 07:28:07 on pts/0
FreeBSD 10.2-RELEASE (GENERIC) #0 r286666: Wed Aug 12 15:26:37 UTC 2015

Welcome to FreeBSD!

[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]#

From then on you can modify pf to suit your machine settings as needed.