News for hackers. Stuff that matters.
Re:Podman: A tool for managing OCI containers and pods by nickstinemates on Thursday September 02, 2021 @11:26AM (#28393234)
Sounds like a chroot with extra steps
Re:Podman: A tool for managing OCI containers and pods by detaro on Thursday September 02, 2021 @11:42AM (#28393472)
That's a way to describe pretty much all container things in a superficial way.
Re:Podman: A tool for managing OCI containers and pods by scatters on Thursday September 02, 2021 @12:52PM (#28394390)
It's not even superficial. A chroot is a limiting case of a container that only rebinds the filesystem; or, equally, a container is a chroot that also rebinds the user namespace, process namespace, networking, etc.
Re:Podman: A tool for managing OCI containers and pods by yakubin on Thursday September 02, 2021 @06:25PM (#28398152)
Can you escape from a mount namespace? You can escape from a chroot.
Re:Podman: A tool for managing OCI containers and pods by majewsky on Friday September 03, 2021 @08:46AM (#28403406)
You can change into an existing mount namespace, which is what commands like "docker exec" or "machinectl shell" do to execute a command within the mount namespace of an existing container. The container can do the same to escape its mount namespace, but it needs privileges to execute the respective namespace-changing syscall, and it needs to know which namespace to change into.

I have an application in a Kubernetes-managed container which needs to do exactly this to access the host system (to open LUKS containers and mount their contents), so I have it run in privileged mode (i.e. with access to all syscalls) and give it the full host filesystem as a bind mount, so it can do:

  nsenter -m /host/proc/1/ns/mnt mount $DEV $PATH
(The actual nsenter invocation is slightly more complicated, but that's the basic gist.)

Side-note: Since there will inevitably be a comment along the lines of "but then what do you even need isolation for", I'm very explicitly using Kubernetes as a deployment mechanism only. Other pods within the same Kubernetes are strictly isolated, but this one deliberately runs with practically no isolation. But I still get the consistent environment that Kubernetes provides (rolling upgrades, log shipping, liveness probes, etc.).

Re:Podman: A tool for managing OCI containers and pods by silisili on Thursday September 02, 2021 @12:11PM (#28393849)
I know this was made tongue in cheek, but that was my first thought as well. Seems it would be more valuable for one to explain how and why it's better than a chroot, instead of redescribing how a chroot works but adding the word container.
Re:Podman: A tool for managing OCI containers and pods by kbenson on Thursday September 02, 2021 @12:59PM (#28394483)
It really just goes to what containers are. You can think of them as at a simple level as tars of chroots you can pass around and that an ecosystem of tooling has built up around.

This allows you to easily deploy generic ones you download from the community, and since they usually ship the script that was used to build it, it's easy to extend them with your own changes by creating your own script that uses a generic public one (the base, not the script) as a starting point, allowing everyone to share work. (e.g. get an nginx container and do the small bits to customize it for you in a script, and you don't need to worry about the building or system setup of container)

In addition to the normal chroot stuff, it uses cgroups functionality on linux to constrain it even more such as limiting CPU and RAM or disk IO, and can lock down a bunch of functionality from even root inside, and you also usually have to specifically allow whatever internal ports are listening externally (and not necessarily on the same port).

So containers are what you get when you take the idea of a chroot and try to extend and build upon it towards the direction of a true virtual machine, but without going to the step of fully emulating hardware. The benefit is that they are super lightweight and can more easily share CPU and RAM. The downside is that you're exposing more of your base system kernel to it, so it's likely somewhat less secure than a true hypervisor (but very likely more secure than just running those processes on the base system).

So, now that we have a shared base of what a container is (sort of, I'm not sure enough on the specifics to assume I didn't make some missteps in that description), rootless containers extend that so that a regular system user can run a container which internally runs as root, but not the real parent system root, but it works for the container because the kernel uses namespaces to allow it. This is both cool because it allows for root to be used even less on a system and scary because as another comment in this thread noted, it exposes some kernel APIs to "root" users (run and controlled by system users) which might not normally be checked as much for security problems since you have to be root already to use them.

Re:Podman: A tool for managing OCI containers and pods by japanuspus on Thursday September 02, 2021 @05:36PM (#28397678)
Also: Julia Evans has a great writeup along these lines:

https://jvns.ca/blog/2020/04/27/new-zine-how-containers-work...

Re:Podman: A tool for managing OCI containers and pods by silisili on Thursday September 02, 2021 @01:49PM (#28395139)
This is actually a really helpful write up - that makes sense. Thank you.
Re:Podman: A tool for managing OCI containers and pods by Spivak on Thursday September 02, 2021 @01:27PM (#28394862)
chroot only affects a processes view of the filesystem it doesn’t affect:

- the process’s view of other processes (i.e. ps isn’t isolated)

- the process’s view of the kernel’s VFS, (i.e. mount isn’t isolated)

- the process’s view of the networking stack (i.e. ifconfig and iptables aren’t isolated, and socket numbers are global)

- the process’s view of users on the system (i.e. uids/gids are global)

And so with time, the hostname, IPC, cgroups…

And more are planned on being added like the kernel keyring, and /dev/log.

“containers” means a lot of different things to different people but the main things people want are.

- resource bundling: “take everything your app needs to run, and tar it up so that it all stays together. Don’t make me worry too much about missing libraries.

- sandboxing: don’t make me have to worry too much about what else is going on the system when I run my thing and reduce the surface area for attacks.

- delivery (the big value add): give me a bunch of tooling to create that tar, version it, and get it running on a bunch of different systems without have to worry too much about the underlying OS, hardware, network setup, or storage.

And bonus for things like k8s.

- service bundling: give me a bunch of tooling to get many of those tars running on different systems and don’t make me worry too much about service discovery, load balancing, software crash recovery, hardware crash recovery, deployments, task scheduling, secrets, config files and more.

Re:Podman: A tool for managing OCI containers and pods by cpach on Thursday September 02, 2021 @12:21PM (#28393980)
Some pointers if anyone is curious about chroot vs other isolation techniques:

https://fly.io/blog/sandboxing-and-workload-isolation/

https://devops.stackexchange.com/questions/2826/difference-b...

For further reading, searching for ⟬docker vs chroot⟭ yields a bunch of interesting articles.

Re:Podman: A tool for managing OCI containers and pods by bjt on Thursday September 02, 2021 @12:23PM (#28394001)
chroot just isolates the file system.

A "container" (whether Docker or LXC or Podman) is a bundle of isolations that includes the filesystem as well as processes and users, and constraints on memory, CPU, networking, and kernel calls.

Re:Podman: A tool for managing OCI containers and pods by chriswarbo on Thursday September 02, 2021 @09:05PM (#28399346)
AFAIK Docker, LXC, Podman, etc. are actually all the same underneath: they use 'runc', which chroots into a directory (along with extra restriction/config via cgroups, bind mounts, etc.).

The differences between Docker, LXC, Podman, etc. are the config, management, etc. of containers; e.g. Docker abstracts over the chroot directories, using a set of content-addressed tarballs (called "images"), and provides commands for starting/stopping/listing/etc. the containers that are running.

Re:Podman: A tool for managing OCI containers and pods by bjt on Wednesday September 08, 2021 @05:02PM (#28463026)
Dating myself a little, but LXC came along well before runc. It predates Docker, and was actually wrapped by the first versions of Docker. I learned about LXC, and used it, after doing some research on how to build my own PaaS at work (pre-Docker) and reading that Heroku was using LXC for their platform. It worked decently for me, but required more in-depth knowledge of all the knobs for disk mounts and networking than Docker typically requires.

You may be right that LXC has switched over to runc since then. I haven't kept up. I would be surprised though.

Re:Podman: A tool for managing OCI containers and pods by nickstinemates on Thursday September 02, 2021 @08:39PM (#28399204)
I was actually being serious, your comment is more helpful though.