Post by @mcc@mastodon.social
So I got today a pretty aggressive sell for moving all my online services to Docker [or podman, whatever, IDK]. Which is something I was already considering for security reasons, but it was argued to me some of the advantages of nix/guix I was interested in (clear separation of content, configuration, and software on my server, easy redeployment) I could get with just Docker.
Okay. Actually this all made sense. But now I have a question.
Why the fuck do I need Linux if I have docker? (1/3)
Put a different way, I've got a couple VPSes. I've got services/sites running on each one. Each is hard nailed to the VPS it's running on. In the docker/podman world I guess I'd have a container for each of my sites (hopefully I don't need an nginx for each site), and a container for mysql or something, and a container for the two non-apache app servers I run. That's… everything I do on the VPS, except log in and fuck around with vim. Could vim, and man, and gcc, be a container? (2/3)
And then what is the Linux distribution itself providing? I just need it to launch and supply kernel+systemd, right? (My VPSes are VERY low disk, low RAM— so I'd worry about all these docker images increasing that.) Wouldn't it make sense to use a distribution that does NOTHING else? Like… uh… examples Kagi gives are "CoreOS" and and something discontinued, and maybe Alpine, though I thought Alpine was about Musl. Assume I actively distrust Redhat. What's the *smallest* podman-host Linux? (3/3)
Other, weirder questions:
- I keep hearing people complain about docker "only being able to inherit from one other" container specification. I was told tonight docker-compose.yaml comprises a "container" which can compose a number of "images" (make fun of me for not knowing these basic things if you wish; I learned Linux in 1998, and nothing changes that). What is the single-inheritance rule, if it's real, concerning? The container? Image specifications? Is podman different in this sense? (4/3)
- What the fuck is Oracle https://docs.oracle.com/en/operating-systems/oracle-linux/podman/containers.html#containers trying to say in this screenshot?
- What does podman use instead of a docker-compose file? Does it just use docker-compose? This doc https://docs.podman.io/en/latest/markdown/podman-compose.1.html says it has the option of using "podman-compose". If I Kagi for that, I get… that same link, the podman-compose manpage (the dash being only a manpage convention).
MUST I write YAML files? Terrifying. I need structural editors for LISP and YAML so I don't have to touch them directly (5/3)
@mcc If it helps at all, "all" valid json is valid yaml, so you can just json it if you speak json.
("all" except for some gross bugs in the spec)
@nonnihil One solution would be to configure an editor to syntax-check a file for json, and then edit my .yaml files in that mode
@mcc this is the implementation https://github.com/containers/podman-compose
When I've tried to use it, it had some rough edges around restarting containers, although maybe I was using it wrong
@mcc at that point I felt like I learned enough and got distracted from whatever toy project I was doing
@lambdageek Thanks. Can you clarify one thing?
I am trying to figure out the compose *format*. The way I specify containers. Are "docker-compose" and "podman-compose" *file formats* or *programs*? The link you gave links "Compose Spec" https://compose-spec.io/ (alarming page), which claims Docker supports it. Are podman's compose format and docker's compose format implementations of this spec? *Variants* of that spec?
@lambdageek @mcc Same. podman-compose just really sucks. Fortunately, you can use podman as a docker "engine", so it even works with the docker CLI.
`docker-compose` calls the docker CLI. `docker compose` is the bundled version that's recommended nowadays. And to further complicate things, the podman CLI also has support for docker-compose as a "compose provider" lmao
@mcc RE: the screenshot.
Docker runs a single docker server as root. That server runs your containers, and the docker cli talks to it through a socket. podman runs as your local user.
the security implications is that anyone who can run the docker cli has to be a member of the docker group, and they can run containers as root. so they could run a container that mounts your host filesystem and then do whatever.
@bdod @mcc i see that argument at times (docker vs podman), and if this is the case you already got bigger problems. they both have their places but they're different security models. both can suck if you make bad decisions, and both can be good if you don't. podman, just so you know, is from the Company you Distrust.
@BlaynePuklich @bdod hm. But Docker is also from a company I distrust. And additionally Linux is a product of two companies I distrust (IBM and NVidia)
@mcc No worries. I can help. A container is basically a filesystem that gets mounted, and a program runs within it (like fancy chroot). Those saved filesystems are called images.
When a container image is built, you usually start with a base image (often based on an existing distro) and then change things as you need. However, containers use OverlayFS. So every change is a layer added to the previous layers.
And while making your image, you can mount other images, and either perform tasks or add files from it to your own.
@mcc re that oracle page: docker is systemd - there's a single all powerful process with a socket into which you shove commands. Podman is a pile of binaries and shell scripts and in fact you are allegedly able to run pods without having to be root.
@lambdageek @mcc we do this at $work for some things. We have different system users for different compose stacks so outside of the containers there's still separation of concerns for security and resource management purposes. It's more painful to do all that, but in some projects it's worth it.
@mcc no, sorry, that was dry humor. I meant the architecture sort of resembles systemd: it's a single binary running as root that does everything and you talk to it through a socket using the "docker" cli command. When you run "docker run" it just sends a command to the daemon telling it to do the actual running
@mcc Now for the compose. Compose is a Docker thing. Podman can run docker-compose files using the podman-compose program (might need to install it separate) by going into the directory with the compose file and running:
podman-compose up
However, and this depends on how deep you want to get into it, Podman also has a feature called quadlets. With that, you can write container definitions using a systemd service file format and run them with systemctl.
@mcc If you want to see what that looks like, I started (but never finished) working on cleaning up and sharing my container files.
https://codeberg.org/bryanredeagle/quadlets/src/branch/main/nginx-proxy-manager
I also have a post on my long abandoned blog about seeing up DNS in a pod. A pod is basically a group of containers that can reach each other with localhost instead of the virtual LAN that Podman sets up. Containers by default run behind a NAT on the host.
@mcc Oh man, my client did not load the whole test of the thread.
Docker runs as root. And a lot of containers run as root (unless the developers took care to fix that). Unless you understand and take a lot of precautions, there are ways for bad actors to get into containers and break out of them. It's a whole thing.
@bryanredeagle Other people are talking about something called "podman quadlets" which sound like they have a more sensible security model (although possibly they are harder to use?)
@mcc Quadlets are the thing that uses a service file like config (I sent a couple links just a moment ago). Podman is considered more secure that Docker because it doesn't run as a daemon under root. When you make a Quadlet, it runs under whatever user you set it up for. So you can run it as a non-root user.
However, it's not like other systemd services where you set the user in the service file. You need to place the Quadlet in a special folder, configure systemd to let the non-root user stay logged in, and then run systemctl in user mode.
It's a real pain in the ass.
Somewhat distressed as my reason for even considering this was I was thinking "if I use docker/podman, I get nix/guix plus a security isolation layer!" and here I have many responses saying "do not use docker as a security isolation layer". Well wtf do I use if I want a security isolation layer then (6/3)
@mcc if you're already using guix/nix, then you don't necessarily need docker since `guix container` gives you the cgroups-level isolation. if that's not enough then there's also `guix vm` to summon a fully virtualized sub-system iirc
@mcc you can actually use Nix with containers where it does isolation as well as package management for you, and it's a lot better than Docker
@mcc I think you were recommended systemd-nspawn before, it's using that and it's something I have chosen for some services in the past https://wiki.nixos.org/wiki/NixOS_Containers
@mcc the other nice thing about NixOS is that many services come with hardening at systemd level which is comparable (in principle, it varies service by service) with that provided by containers. for example, the git-pages executable cannot use the "load kernel module" syscall (among many others), which limits consequences of compromise
@whitequark There is also a 3rd party tool to define full NixOS virtual machines. I have not used it much, but I am considering testing it out: https://github.com/microvm-nix/microvm.nix
@whitequark Just for clarity: When you say "and it's a lot better than Docker" do you mean "and it's a lot better than Docker" or "and it's a lot better than Docker or Podman/quadlets"?
@mcc what it gives you is centralized package management, so Docker and Podman are similar in this aspect (Podman doesn't have the Docker control socket, but they're both have the issue that you can't just upgrade every dependency in a container easily)
@mcc It's mostly because there are ways to break out of the container. You can protect against that by running the container as non-root, and/or run the user inside the container as non-root.
You can run into networking issues if you need a privileged port, though.
The real dream would be if Linux had BSD jails or Solaris zones.
@mcc
I learned Linux in like 1995 or whatever too. Docker is one of my least favorite trends... But ive kinda learned the raw container stuff a bit because network namespaces for router things...
Docker was written by people who think NAT is good and had never heard of ipv6... their ipv6 solution appears to be also NAT, so they appear to be provably bad.
@mcc
The purpose of Docker is to contain a minimal set of programs, just a web browser, or just a database, or just the combination of a database and a REST endpoint to query data, or whatever. It CAN contain a whole OS but it really assumes youre containing just one app...
@mcc
So, you need the base linux system to be the host of the containers, and you need the Docker/podman/guix container to be the slice of resources that the app gets to use.
Note I think podman improved the networking thing but I'm not sure.
Okay. Let me ask the question in the above post a little more clearly:
If someone says "podman is not a security isolation boundary", do they mean anything more or less than "if the kernel has privilege escalation vulns, then the kernel has privilege escalation vulns"?
(Clarifications: When I say "podman" in this post, I mean "podman", not "docker"; also, I am reading that podman uses SELinux, but I'm not clear if it ALWAYS uses SELinux or uses it 'in some configurations'. I know nothing)
@kouhai Thank you. Next question: Does the "some configurations" for podman with SELinux meaningfully constrain my choice of linux distribution?
@mcc I recently set up podman. by default the daemon is configured to run as root. it is possible, but surprisingly hard, to comfigure it to run as less than root. so, anyone who needs to start a container can also use the daemon to pivot into root. this is a Linux thing, I do not know why this is the default config. it was a few months ago so I am likely wrong on details but it differs a lot from e.g. docker desktop on macOS where containers run inside a vm under your user.
On the security question: _basically_ that, but also: not everything gets namespaced, and actual device files get mapped in. And often one ends up giving the container capabilities which are effectively root equivalent.
If you do end up using the systemd "quadlet" approach, there's a bunch of stuff which you can tighten as you like.
@mcc "docker|podman is not a security boundary" is typically followed with a sales pitch for a cloud vendor's hardened container runtime - AWS firecracker/fargate, GCP gvisor.
Which is to just say that you can run docker engine/podman out of the box and have it be a weak security boundary, and then later change it to be better without affecting your workload inside the container.
@mcc Generally Podman is just better in security because it is based on default privileges by the current user.
There is no root daemon like dockerd for Docker running the service, and podman uses a rootless privilege model (as described above).
So even if it isn't using SELinux in some configurations, it is exceptionally much better than Docker in terms of security.
I am also attracted to podman more because it is community driven rather than business driven like Docker.
@mcc I think the security boundary argument is exactly that you are sharing a kernel, and I went from "that's being paranoid" to "okay maybe it's a valid point" with all the vulns coming out.
krun is an interesting approach for VM-ising your podman container without changing much for common cases.
Also, the nix ecosystem has ways to generate Docker/OCI images, so you can have the best of both worlds if you want.
@mcc basically it’s a really big attack surface and the kernel namespace features are primarily designed to prevent non-malicious apps from interfering with each-other.
@mcc An important part of the "insert container runtime here is not a security boundary" story goes in the opposite direction of what some of the replies here have gestured at - namely, something like the following:
Assume that there exist certain privilege-escalation vulns in the kernel. (A fairly solid assumption here in late 2026, lol.)
Assume that those cannot be accessed through, I dunno, straight-up SSH into the box where that kernel runs, but instead require an app to be running there that itself has some vuln that allows you to go from
app listens for HTTP traffictoapp executes arbitrary code in userspacetoarbitrary code exploits kernel privilege-escalation vuln.Now, if that app is running in a container, and on the same machine, you're running another app, in a different container, that second app is still every bit as vulnerable to this attack vector as it would be if the two apps were running directly, not containerized, on the host box. (I.e., you can compromise the kernel from one app, and use that access to mess with the second app, regardless of the container boundaries.)
Now, depending on one's understanding of kernels, containers, etc., the above might seem rather trivial. But you'll be surprised how many not-completely-technical people are surprised by this reality (that one app can compromise another app this way, even when they are both containerized). So a cynic might say "a compromised kernel is a compromised kernel, duh"; the point here can be summarized as "when an attack vector transits through the kernel, containerization will do nothing for you, security-wise."
(Sorry for the super-long poast.)
@mcc I expect you have all the answers you need, but I actively run all three of Guix, Docker, and Podman and I would be happy to clarify if you have questions about any of them.
@ieure Hello, I am *very* interested to pose you some questions, but I think I need to spend about a week first thinking what the questions are.
If you like the systemd style of key/value unit files, this is a nice way to do things:
https://docs.podman.io/en/v5.0.1/markdown/podman-systemd.unit.5.html
Most containers can run rootless with podman. I have Home Assistant set up this way on Fedora IoT, with the containers all in a `hass` account.
It's pretty slick — systemd and podman keep the containers running and up to date, including automatic roll-back on failed updates.
If you hate the systemd way of doing things... probably less what you want :)
@mattdm Actually, I think I do like the systemd way of doing things. I mainly freak out about YAML because I find the format ambiguous and it has caused errors in software I used with YAML in the past.
@mcc @mattdm For "works without making too many assumptions about the container host", I've been using the podman-compose option (which does just use docker-compose.yml files). I wouldn't use it if I controlled the container host, though - the native podman+systemd integration looks much nicer when you can rely on being able to update systemd and the kernel as necessary.
@mcc if you have issues with docker-compose or there's something it can't do, you can switch to bash scripts. I suppose it's the same with podman.
I usually use bash scripts from the beginning because I don't want to learn another way of running containers and I don't like yaml.
The docker CLI is kind of intuitive, why must I learn another interface?
@mcc@mastodon.social Podman, last I checked, doesn't suppor docker-compose, which is why I don't personally use it despite some real technical advantages. They used to support a docker-compose-like implementation, but it's now unsupported as they're working on some new swoopy thing called ... Quadlets I think?
FWIW you can lint your YAML with yamllint: https://github.com/adrienverge/yamllint
Also, I suspect you know this by now but you need Linux for Docker because Docker is a specific Linux thing as it rests upon a Linux kernel feature (cgroups).
docker compose is my favorite way to configure and deploy self hosted apps. There are a number of grizzled sysadmins who will spew fire and brimstone at you if you mention docker. We're all supposed to suffer with using distro packages for everything. Great in principle, a nightmare in practice :(
@feoh Above I link the manpage for the "podman compose" command; it says "The default compose providers are docker-compose and podman-compose". Something may have changed. I have no information on whether quadlets are different.
@mcc@mastodon.social Maybe! Good luck with your explorations!
What I remember is that podman compose exists but that there wasn't actually enough of docker compose implemented to allow me to actually use "off the shelf" docker compose files or snippets to manage my deployable software.
Hope it's different now, please do post if you have good luck!
@mcc you could use dhall lang (a configuration language) to generate the yaml. I don’t know if this fixes your issues with yaml and it’s another thing to learn. Maybe you can even find dhall modules for docker/podman that reduce the amount of work.
@mcc with podman you can make use of systemd, the podlet cli tool can be used to comvert docker compose into systemd units (maybe you have an ksp for those:3?)
@mcc dockerfiles have a "FROM" statement which specifies the container to inherit from… but one can use multiple "FROM" statements in the same docker file, but only one of them is active at a single time. (so, one can swap the base container underneath during the container build, useful e.g. to first build an executable in a normal container, then base the final image upon the special "scratch", which is effectively empty)
@mcc one can kinda merge multiple base images together, but it's ugly. (and doesn't make sense when they're multiple complete linux distros, etc.)
so this limitation is only about storage efficiency (because merging stuff from multiple images implies copying, whereas the layer to inherit from is shared / copy-on-write)
@mcc images are built from “layers” of overlay filesystems. The way docker builds images is running imperative installs inside and then snapshotting the overlay filesystem to save it as a layer. The building process only supports running on top of existing layers, not using layers as mixins. This is relevant when dealing with “Dockerfile” / “Containerfile” building new images.
@mcc I'm not sure what complains are you referring to, exactly.
Docker images are defined by dockerfile, and typically each image (besides the most basic ones like "Debian" or "Alpine") is defined as "take that other image and do certain manipulations with it and store the result" (so you can have e.g. "mastodon server" image).
Docker compose file can define multiple containers and their interactions (e.g. "I want there to be a mastodon backend server to be running (from that image) and accepting requests at this external host:port, and I also want there to be postgres server to be running (from that other image) and have this host directory with this path be mounted in it under this path for storage; and also I want there to be a private network connecting mastodon server and postgres, with them having the following IP addresses there", something like that)
@mcc I think we've used these "distroless" ones from Google at a few of my jobs: https://github.com/googlecontainertools/distroless
@mcc we used to use Alpine as a base for docker images. I ended up hating it because they removed slightly older packages, so our Dockerfiles would no longer work. This was not a security thing. They just seemed to have a policy of removing the old one from the repo when a new one came along.
@mcc we were deploying to kubernetes. Totally dissimilar to what you’re looking to do. What got me was not being able to repeatably rebuild the image (we would bake in our app, but needed the base image to start from). If you based your host on alpine, you could just plan on not being able to rebuild it without much futzing.
@edebill not being able to rebuild without futzing is scary because isn't a rebuild a prerequisite for incorporating security updates?
@noisytoot I mean I *think* I want systemd, but the docker advocate I was talking to tonight seemed to be trying to convince me docker *replaces* systemd? I no longer configure, start or stop systemd services, just docker images with services inside them? Is that false?
I'm torn because systemd is known to incorporate AI slop, but I would go to considerable lengths to avoid interacting with openrc
@mcc correct, Linux just supplies the kernel upon which containers are built
a lot of container strategies really do pretty much use the host as a hypervisor
Alpine is used because it is very small and efficient to support single applications, most constantly updated distros just do not have such a small install size
@mcc you probably don't trust Apple either, but our containerization thing has its own minimal init that runs in the base linux vm and sets things up for the OCI image to be able to start https://github.com/apple/containerization/tree/main/vminitd
@joe *rubbing eyes* this is *Linux* containerization?
Does it work on Apple Silicon? Does it require Apple Silicon?
I have two problems I'm trying to solve. A short term problem is that my VPSes are falling apart and I need some sort of plan that allows me to back them up and migrate them non-awkwardly. A long term problem is I want to move off dependence from actors (IBM, Apple) I have reason to believe are using "AI code assistants".
@mcc yeah, this is so you can run a Docker-style container inside of a VM on macos. while the host side of things is obviously gonna be mac and apple silicon specific, i don't think the init implementation itself needs to do much that's nonportable. apple stuff is not going to get you away from AI nonsense alas, but i thought it was interesting as an example of how minimal the glue between kernel and OCI can potentially be
@joe That *is* interesting. To be clear, is it possible to run this *WITHOUT* MacOS? Is OpenDarwin still a going concern?
@mcc well, i doubt it runs with anything other than the macos container daemon out of the box, since that's what it's designed for, and it looks like it uses vsock to talk to the macos-side daemon
@mcc I've been hearing interesting things about IncusOS, but sadly haven't had time to sit down with it... maybe over the holiday...
Also, if I were starting from scratch, I'd probably try Amutable as the base OS. https://amutable.com/foundations#os
(But also having started with Linux in the 90s, I'm not sure I could adjust to not sshing in to do things.)
@mattdm "can't ssh in" is kind of a no-go for me, depending on what that means. i routinely edit html files in vim…?
@mcc Alpine is general purpose Linux but it's really small, IIRC the entire system with all the installed packages takes like 4GB on my desktop (and this includes things like Firefox, Chromium, Thunderbird, VSCodium, LibreOffice etc)
@mcc Any Linuxy thing could be a container but it would probably make sense to just have vim etc be part of the build (Dockerfile) for all of your other containers. Developing inside of a container is kinda odd... you might mount a directory back to the host to contain the repo/code:
docker run -t -i --name=foo -v /home/mcc/project:/opt/app imagename /bin/bash
Otherwise the contents of containers is only kind of persistent. After you create the container, it'll have persistent storage until you rm it, so it's really easy to (intentionally or accidentally) delete a container's storage is more apt. So mapping a partition back to the host is a good idea for dev work.
@mcc Developing inside a container is fine. I just suggest mapping a directory back to the host so work doesn't accidentally get lost. There is persistent storage until you 'docker rm' the container, but it's easy to rm the wrong container if you're making lots. General use idiom is that creating and rm'ing containers is normal and common, so that makes storage data in containers dangerous. The running container creates another unionfs layer on top of the other layers the container is built from...
@mcc I run containers for all my deployments (podman). Usually one per service. The more complicated ones sometimes need multiple, which I run in a pod (a bundle of containers that see each other in the same localhost). It is rare, but for some services I do run an extra nginx that puts things together and is a container of itself.
As for the last question, avoid tooling as much as possible inside containers. Tooling for you is tooling for the attackers.
@categulario What if I put the tooling inside its own container and therefore the attackers can't use it because they're not in that container
@mcc yea, possible, then to actually use it you would plug another container's volume(s) into that one to use. Not very ergonomic but sometimes useful.
I do that sometimes, I created an image that has my tools and setup, but it is seldom used in practice.
@mcc One reason to keep separate VPSes is that Docker is not really meant to be used as a security boundary. Containers all share the same copy of the kernel, so if you can exploit the kernel, you can escape the container.
@mcc I don't know that I have a good answer to that besides a VPS unfortunately. Which isn't to say that a better answer isn't out there, just that I don't know one (and I am far far from an expert on docker).
