Here is the setup I have to run Ubuntu inside the jail:
- Run a thick jail with FreeBSD environment where
exec.start = '/bin/sh /etc/rc'
- Install ubuntu environment say under
/compat/jammy inside the jail with appropriate settings to the host node to enable Linux Compatibility Layer
- Mount devfs, linprocfs, etc. under
$path/compat/jammy in the jail
- Use rc.local to start SSH and other Ubuntu services
Code:
chroot /compat/jammy /usr/sbin/service ssh start
SSH into Ubuntu jail and work as if a Ubuntu server.
As was mentioned above, Ubuntu relies on systemd. It makes such setup generate errors from time to time, when in need to change some settings using CLI tools that rely on systemd. I have to bypass this limitation by manually changing appropriate configs + friends in the old fashion and it seem to work.
Of course bhyve would be a bit more appropriate to run more-or-less full Ubuntu stack including Kernel, but that's a different story.
As an alternative solution, there is a very short but helpful page on running Alpine Linux in a jail, without FreeBSD environment:
https://it-notes.dragas.net/2024/01/18/installing-alpine-linux-on-a-freebsd-jail/. Of course, it is a different Linux distribution, but must smaller (Ubuntu 24.04 Server ISO is ~3GB, Alpine mini root filesystem is ~5MB).