I have been looking for a Docker
image of FreeBSD
but cannot find, can FreeBSD be run inside docker? If not, why not?
-
Those ones don't work? (https://hub.docker.com/search/?q=freebsd&page=1&isAutomated=0&isOfficial=0&starCount=0&pullCount=0) – VonC Nov 23 '15 at 05:28
-
The person who submitted an answer says it needs a FreeBSD host – Phil Nov 23 '15 at 08:19
2 Answers
EDIT FROM THE FUTURE: No, you can't, none of the below projects ever went beyond prototypes.
Technically yes, but you need a FreeBSD host to do it and Docker is "somewhat unstable" on FreeBSD right now. There is a fork from Docker 1.7 that can technically launch containers, but nothing you would want to use for reals. Jetpack will hopefully be finalized for FreeBSD 11 and will provide a much better solution here.
https://wiki.freebsd.org/Docker has info. You can make it work on a fully updated 10.3 but expect lots of weirdness.

- 52,400
- 4
- 52
- 75
-
3
-
7Because you can't run FreeBSD binaries on a Linux kernel/libc. Docker (and Jails, Zones, etc) just runs a process with lots of special flags, but at heart they need actually run. – coderanger Nov 23 '15 at 05:42
-
5The Docker FreeBSD port is not "*somewhat unstable*", it's outright unfinished. Virtualized networking, resource limits, volumes and links are not there. Furthermore, there hasn't been any activity for over 1.5 years. The project looks abandoned. – rustyx Mar 10 '17 at 20:44
-
7Many years ago it seemed like it might be a thing but both Docker on FreeBSD and Jetpack are now abandoned. – coderanger Mar 10 '17 at 22:50
-
@Phil you can't because Linux and BSD using a different kernels like...totally. The only similarity between Linux and BSD are - they POSIX compliant and that's it. Docker isn't a virtualization software like KVM, it only isolating processes by using underhold Linux kernel capabilities. That's why it's a pain to port docker to BSD, same as execute BSD application on non-BSD system. – Reishin May 16 '22 at 08:34
There's a lot of caveats here but yes, you can and no its not depended on FreeBSD (but openbsd may not work).
#!/bin/sh
wget https://download.freebsd.org/ftp/releases/ISO-IMAGES/13.2/FreeBSD-13.2-RELEASE-amd64-bootonly.iso
cat -> docker-compose.yml <<< EOL
---
version: "3"
services:
freebsd-via-qemu:
image: jkz0/qemu:latest
cap_add:
- NET_ADMIN
devices:
- /dev/net/tun
- /dev/kvm
volumes:
- ./FreeBSD-13.2-RELEASE-amd64-bootonly.iso:/image
restart: always
...
EOL
docker-compose up -d
The above shell script would download the boot only iso for FreeBSD then spin up a QEMU container which in turn boots the os. I do this with other systems like Plan9, SimH, MVS, Freenas, AROS, and VyOS. And yes this does work with Podman, WSL, or K8S too.
Now for the caveat here, this is clearly not a hypervisor running in Ring 0, but a x86 emulator running in user space and jailed off at that. Your not going to get any performance out of this setup and may see some issues with device drivers or worse just outright be unusable for anything other than as a toy/research.

- 1,472
- 16
- 22