14

How to run *BSD (Open, Free, etc.) on Docker?

I am using Docker for Mac.
But There is no BSD image on Docker Hub.
How I can run it?

KiYugadgeter
  • 3,796
  • 7
  • 34
  • 74

1 Answers1

20

Docker doesn't actually run a full OS. Because it uses the host's kernel to run the container contents, it's not able to run a different kernel than the one used by its host OS. Further, as far as I understand, Docker relies on Linux-specific features for its fundamental operation. So it's not possible to run it with a BSD or another non-Linux kernel, including the XNU kernel used by MacOS, as its host environment. On a Mac, Docker actually runs within a virtualized Linux environment, so its host environment is Linux.

Now, in theory, if someone got a BSD userland to run on a Linux kernel, it might be possible to have a nearly-BSD Docker container. However, some research suggests that no project doing this has succeeded.

All of that means that there's no way to run a true BSD as a Docker image, which is why there is no BSD image for Docker.

andyg0808
  • 1,367
  • 8
  • 18
  • 8
    To add to this answer, if you need something similar (separate userspaces running under a single kernel) for FreeBSD, it has [Jails](https://www.freebsd.org/doc/handbook/jails.html). – cynic Sep 15 '16 at 11:55
  • 4
    Docker is abstracting away from Linux specific features to relying on the [OCI runtime spec](https://github.com/opencontainers/runtime-spec). Windows now has an OCI implementation that Docker can run windows containers on. OCI is heavily based on the container features that were built into Linux though. – Matt Sep 15 '16 at 13:27
  • 2
    Also it's technically possible to run a [FreeBSD image](https://hub.docker.com/r/lexaguskov/freebsd/) on a [FreeBSD host](https://wiki.freebsd.org/Docker) but this sort of cheats by relying on FreeBSD's Linux ABI compatibility layer in the first place. – Matt Sep 15 '16 at 13:29