Running podman containers in bhyve in OpenIndiana Zones#

First you need a running OpenIndiana installation on an amd64 system that supports bhyve. You can check bhyve compability with

(709) x230:/root# ./bhhwcompat   
CPU vendor string: GenuineIntel
... CPU supports VMX
... VMX support is enabled in BIOS
... VMX supports TSC Offsetting
... VMX supports VM Exit on MWAIT
... VMX supports VM Exit on MONITOR
... VMX supports VM Exit on CR8 Load
... VMX supports VM Exit on CR8 Store
... VMX supports Unconditional I/O exiting
... VMX supports MSR bitmap
... VMX supports Interrupt-window exiting
... VMX supports NMI-window exiting
... VMX supports Secondary VMX controls
... VMX supports EPT
... VMX supports VPID
... VMX supports Unrestricted Guest
... VMX supports single INVEPT
... VMX supports all INVEPT

bhyve is supported on this system.

If bhyve is supported, install a few packages:

# pkg install system/bhyve system/bhyve/firmware \
> system/library/bhyve system/zones/brand/bhyve

Now you need a Linux ISO image. I chose RHEL 8.5 in my case, but you can pick any other. Just one word of attention here: some Linux distros have issues with the EFI firmware of bhyve, RHEL 8.2 refused to boot. The issue was fixed in 8.5 at least.

Set up a vnic for networking:

# dladm create-vnic -l e1000g0 bhyvevm0

Set up a ZFS volume for the VM image:

# zfs create -V 20G -o compression=lz4 rpool/bhyvevol0

Now we set up a zone:

# zonecfg -z bhyvevm <<EOF
create -b
set zonepath=/export/zones/bhyvevm
set brand=bhyve
set autoboot=false
set ip-type=exclusive
add net
set physical="bhyvevm0"
add fs
set dir=/rpool/iso/rhel-8.5-x86_64-boot.iso
set special=/rpool/iso/rhel-8.5-x86_64-boot.iso
set type=lofs
add options ro
add options nodevices
add attr
set name=cdrom
set type=string
set value=/rpool/iso/rhel-8.5-x86_64-boot.iso
add device
set match="/dev/zvol/rdsk/rpool/bhyvevm0"
add attr
set name="bootdisk"
set type="string"
set value="rpool/bhyvevm0"
add attr
set name="vnc"
set type="string"
set value="on"
add attr
set name="acpi"
set type="string"
set value="off"
add attr
set name="bootrom"
set type="string"
set value="BHYVE_RELEASE"
# zoneadm -z bhyvevm install
# zoneadm -z bhyvevm boot
# socat TCP-LISTEN:5905,reuseaddr,fork UNIX-CONNECT:/export/zones/bhyvevm/root/tmp/vm.vnc

Now on another Terminal open vncviewer:

$ vncviewer ::5905

Follow the installation instructions of your Linux distro. After that, install podman on your Linux VM and then you can run containers in bhyve in a container ;)