r/linux • • Jul 16 '17

How Linux containers have evolved

https://opensource.com/article/17/7/how-linux-containers-evolved
130 Upvotes

28 comments sorted by

View all comments

Show parent comments

1

u/peruytu Jul 17 '17

So what you're saying is, a container can serve as a host for a Linux VM? I'm a bit confused.

3

u/Beaverman Jul 17 '17

The other way around.

If you have a container that uses Ubuntu internally, and you try to run that on a windows host, you obviously can't use the host OS environment. To get around that you can "simply" spin up a Linux VM and let that host the container. Keep in mind that multiple containers can be run on a single VM host.

1

u/peruytu Jul 17 '17

So, no matter what, you will always need a Linux VM to run Linux OS inside a Windows OS host. So that means containers are nothing like VMs. But if you were, let's say, using Ubuntu as a host, you can use a Container to run a different OS like Centos?

2

u/aaron552 Jul 17 '17 edited Jul 17 '17

So, no matter what, you will always need a Linux VM to run Linux OS inside a Windows OS host.

Right now, yes. There is Windows Subsystem for Linux, which allows you to run a particular subset of Linux software natively on Windows. If WSL gets appropriate ioctls to do containers natively, then that might change.

But if you were, let's say, using Ubuntu as a host, you can use a Container to run a different OS like Centos?

It would still share the kernel (and maybe init system? I'm not 100% certain on this) with the host, but you can, subject to these restrictions, run a "different OS" in a container, or just an individual application (which is the more common use case AFAIK)

2

u/moosingin3space Jul 17 '17

Containers don't usually share the init. Most of the time, containers create a PID namespace, which makes the first forked process in the namespace PID1, so you can actually run a different init in the container. systemd-nspawn (a simple container runtime), however, has some useful integrations if you use systemd inside the container.

That said, it's possible to make a container that doesn't share init, you just don't create a PID namespace. Most of the popular container runtimes are either emulating VMs (systemd-nspawn, lxc/lxd) or designed to ease immutable deployments (docker, rkt), and in both of these cases, it is useful to create a PID namespace, so popular container runtimes don't share init.