← Back to context

Comment by trod1234

4 days ago

For those not intimate familiar with containers (docker/podman), can you link to a brief blog post that touches on this in detail for further reading? Much appreciated.

> Docker is for organizing things for yourself, just like directories are.

Services have the following dependencies: static data files; configuration files; executable code/binaries; library dependencies.

In days of yonder, you'd need to download/install all of that ^ on each machine where "service A" needs to run. Developers would run and test "service A" on ubuntu 18.04. But production servers had to run ubuntu 16.04 because "service X" that also runs on the same server needs a library that has not been ported to 18.04 yet.

But "service A" needs a library that was never available on 16.04. Welcome to dependency hell!

Containers bundle all of those dependencies into one object that can be downloaded directly onto the host server, ready for the "service A" process to execute. Now it doesn't matter if production servers are running 16.04. Everything "service A" needs is stored inside the container blob (including some minimal ubuntu 18.04 stuff).

the magic that lets this happen -- containers re-use the host server's OS kernel. Running a new ubuntu 18.04 container does not start a new OS kernel running. the process for your container is just 'firewalled' off from all other processes using cgroups [0]. containers re-use the host's kernel, start a cgroup'd process which starts your container's services and processes (the 18.04 'OS' services and your binary/code/executable).

short/simpler version: containers share the core of the underlying operating system on the host server.

> If you want actual isolation you have to take extra steps.

unfortunately, this means containers share the core of the underlying operating system on the host server.

containers not being isolated from the host server OS can present a security risk as you can escape from the container and "do bad things to host server". [1]

In cases where that is a problem you mostly have two choices:

* use VMs instead (a completely isolated OS instance is started for each service, cannot interact with the host OS at all -- this uses a lot more memory/cpu)

* use rootless containers [2] (container processes are launched under a specific user namespace rather than kernel namespace -- escaping the container means you only get access to the user namespace)

[0]: https://en.wikipedia.org/wiki/Cgroups

[1]: by default the docker daemon service and all the container processes it starts are running as root, which means escaping out of a container in a a default docker installation is as bad as giving someone root.

[2]: https://docs.docker.com/engine/security/rootless/