Technology /
25 Jul 2022
(Not) Using Docker on SDF.org
Status (2022-07-26): You can’t, basically. But there are workarounds.
Background
Docker won’t work out-of-the-box on SDF for two reasons: first, because Docker is built to run on the Linux kernel, and SDF runs FreeBSD; second, because Docker also tends to assume root or root-like permissions (e.g. being in the docker
) group, which isn’t allowable on a shared, multi-user system like the SDF. It’s the first one that’s the real deal-breaker; there are ways of getting around the root-user issue on Linux.
Example
This won’t work on SDF (on any server, be it otaku or iceland):
> docker info
Segmentation Fault or Critical Error encountered. Dumping core and aborting.
Abort trap (core dumped)
I’m honestly unsure why Docker is installed on SDF at all, since it’s pretty Linux-y and the BSD community seems less-than-friendly to it.
Alternatives
### BSD Jails BSD jails are usually mentioned as an alternative to Docker, but I haven’t been able to figure out a way of using jails that’s remotely equivalent to how Docker is typically used, i.e. as a way to script the creation of a disposable environment for building an artifact, containing all required dependencies, and then chucking the whole thing when done. It apparently isn’t a thing BSD people… do?
Also, it doesn’t appear that SDF allows users to run jails, even for ARPA and MetaARPA members. It’s not on the master list of installed software.
Linux VM
Another option would be to run a Linux VM, and then run Docker on that.
This doesn’t seem like a particularly efficient option, but it’s basically how Docker works on Mac OS X (which is much closer to BSD than Linux under the hood) and Windows (which isn’t anything like Linux at the kernel level). They actually spin up a very lightweight Linux image which then runs the Docker daemon, since the actual OS kernel can’t do it. This implies the same technique should work just fine on BSD, but for whatever religious reason, the BSD folks don’t seem supportive of actually becoming a supported platform for Docker. Kinda too bad, as I suspect quite a few people would like to run BSD on the ‘bare metal’ and then deploy software on top of it with Docker.
It appears that SDF does have a membership tier that allows VM creation, and it’s pretty affordable: $7/mo or $60/year for a VM with 1GB RAM and 20GB storage. To sign up, you need to already be a SDF ARPA member ($36 lifetime, last I checked), and then you can upgrade using this subscription page. This is the direction I think I’m heading.
Just do remote builds instead
This isn’t really an equivalent, more of a workaround, but it’s probably the cheapest route: instead of doing your website builds on SDF proper, you just do them somewhere else – maybe on a machine at home, maybe using GitLab CI, or a free AWS / Google Cloud instance – and then just push the generated HTML over to SDF, using it solely as a static web host.
References
- Install Docker on FreeBSD - HOWTO for the “Linux VM” option
- BSD iocage - container orchestration for BSD jails, requires root?
- FreeBSD Docs, Chap. 15: Jails - official documentation on jails