Live data from Hacker News

How Container Filesystem Works: Building a Docker-Like Container from Scratch

labs.iximiuz.com

21–30 of 34 posts

Re: How Container Filesystem Works: Building a Docker-Like Container from Scratch

#22
post #9
post #2

We had chroot since 1979, nobody managed to build a docker like wrapper for chroot which do not require netns?

Solaris Zones (follow on to Solaris Containers) was pretty amazing. https://en.wikipedia.org/wiki/Solaris_Containers

Quick note that all these things are pre-dated (by decades) by mainframe virtualization schemes such as MVS.

Re: How Container Filesystem Works: Building a Docker-Like Container from Scratch

#23

Earlier quoted context omitted.

Docker is a genius idea which looks obvious in retrospect, but someone need to invent it. Docker is more than just chroot. You also need: overlay file system; OCI registry and community behind it, to create thousands of useful images. And, of course, the whole idea of creating images layer by layer and using immutable images to spawn mutable containers. I don't actually think that you need network or process isolatio…

What I always wondered is why qcow2 + qemu never gave rise to a similar system, they support snapshots/backing-files so it should be possible to implement a system similar to docker? Instead what we got is just this terrible libvirt.

We called it "VMware".

Re: How Container Filesystem Works: Building a Docker-Like Container from Scratch

#24
post #7

Earlier quoted context omitted.

Docker is a genius idea which looks obvious in retrospect, but someone need to invent it. Docker is more than just chroot. You also need: overlay file system; OCI registry and community behind it, to create thousands of useful images. And, of course, the whole idea of creating images layer by layer and using immutable images to spawn mutable containers. I don't actually think that you need network or process isolatio…

network isolation is very important too, that’s what lets people run 4 containers all listening on port 80 process isolation is less prominent

[dead]

Re: How Container Filesystem Works: Building a Docker-Like Container from Scratch

#25

Earlier quoted context omitted.

Docker is a genius idea which looks obvious in retrospect, but someone need to invent it. Docker is more than just chroot. You also need: overlay file system; OCI registry and community behind it, to create thousands of useful images. And, of course, the whole idea of creating images layer by layer and using immutable images to spawn mutable containers. I don't actually think that you need network or process isolatio…

What I always wondered is why qcow2 + qemu never gave rise to a similar system, they support snapshots/backing-files so it should be possible to implement a system similar to docker? Instead what we got is just this terrible libvirt.

Containerd/nerdctl supports a number of snapshotter plugins: Nydus, e Stargz, SOCI: Seekable OCI, fuse-overlayfs;

containerd/stargz-snapshotter: https://github.com/containerd/stargz-snapshotter

containerd/nerdctl//docs/nydus.md: https://github.com/containerd/nerdctl/blob/main/docs/nydus.m... :

nydusify and Check Nydus image: https://github.com/dragonflyoss/nydus/blob/master/docs/nydus... :

> Nydusify provides a checker to validate Nydus image, the checklist includes image manifest, Nydus bootstrap, file metadata, and data consistency in rootfs with the original OCI image. Meanwhile, the checker dumps OCI & Nydus image information to output (default) directory.

nydus: https://github.com/dragonflyoss/nydus

awslabs/soci-snapshotter: https://github.com/awslabs/soci-snapshotter ; lazy start standard OCI images

/? lxc copy on write: https://www.google.com/search?q=lxc+copy+on+write : lxc-copy supports btrfs, zfs, lvm, overlayfs

lxc/incus: "Add OCI image support" https://github.com/lxc/incus/issues/908

opencontainers/image-spec; OCI Image spec: https://github.com/opencontainers/image-spec

opencontainers/distribution-spec; OCI Image distribution spec: https://github.com/opencontainers/distribution-spec

But then in the

opencontainers/runtime-spec//config.md OCI runtime spec TODO bundle config.json there is an example of a config.json https://github.com/opencontainers/runtime-spec/blob/main/con...

The LXC approach is to run systemd in the container.

The quadlet approach is to not run systemd /sbin/init in the container; instead create .container files in /etc/containers/systemd/ (rootful) or ~/.config/containers/systemd/*.container (for rootless) so that the host systemd manages and logs the container processes.

Then realized you said QEMU not LXC.

LXD: https://canonical.com/lxd :

> LXD provides both [QEMU,] KVM-based VMs and system containers based on LXC – that can run a full Linux OS – in a single open source virtualisation platform. LXD has numerous built-in management features, including live migration, snapshots, resource restrictions, projects and profiles, and governs the interaction with various storage and networking options.

From https://documentation.ubuntu.com/lxd/latest/reference/storag... :

> LXD supports the following storage drivers for storing images, instances and custom volumes:

> Btrfs, CephFS, Ceph Object, Ceph RBD, Dell PowerFlex, Pure Storage, HPE Alletra, Directory, LVM, ZFS

You can run Podman or Docker within an LXD host; with or without a backing storage pool. FWIU it's possible for containers in an LXD VM to use BTRFS, ZFS, or KVM storage drivers to create e.g. BTRFS subvolumes instead of running overlayfs within the VM by editing storage.conf.

Re: How Container Filesystem Works: Building a Docker-Like Container from Scratch

#26
post #2

We had chroot since 1979, nobody managed to build a docker like wrapper for chroot which do not require netns?

Docker is a genius idea which looks obvious in retrospect, but someone need to invent it. Docker is more than just chroot. You also need: overlay file system; OCI registry and community behind it, to create thousands of useful images. And, of course, the whole idea of creating images layer by layer and using immutable images to spawn mutable containers. I don't actually think that you need network or process isolatio…

i tried to build at work something like docker around 2003-2004. was trying to solve problem of distribution/updates/rollblacks of software on network appliances that we made. overlay filesystems back then were immature/buggy so it went nowhere. loopback mounted system was not sufficient (don't remember why)

Re: How Container Filesystem Works: Building a Docker-Like Container from Scratch

#27
post #2

We had chroot since 1979, nobody managed to build a docker like wrapper for chroot which do not require netns?

Docker is a genius idea which looks obvious in retrospect, but someone need to invent it. Docker is more than just chroot. You also need: overlay file system; OCI registry and community behind it, to create thousands of useful images. And, of course, the whole idea of creating images layer by layer and using immutable images to spawn mutable containers. I don't actually think that you need network or process isolatio…

I was a very early adopter of Docker and what sold me was Dockerfiles.

A SINGLE regular text file that took regular shell commands and could build the same deployment from scratch every time and then be cleaned up in one command.

This was UNHEARD of. Every other solution required learning new languages, defining “modules,” creating sets of scripts, or doing a lot of extra things. None of that was steezy.

I was so sold on Dockerfiles that I figured that even if the Docker project died, my Dockerfiles would continue to live because other people would try copy the idea of Dockerfiles. Now it’s been 10 years and Docker and containerization has changed a lot but what hasn’t? Dockerfiles. My 10 year Dockerfiles are still valid. That’s how good they were.

Re: How Container Filesystem Works: Building a Docker-Like Container from Scratch

#28
post #7

Earlier quoted context omitted.

network isolation is very important too, that’s what lets people run 4 containers all listening on port 80 process isolation is less prominent

You can bind your application to 127.0.0.2 for one container and to 127.0.0.3 for another container. Both can listen on port 80 and both can communicate with each other. And you can run another container, binding to 1.2.3.4:80 and using it as reverse-router. You can use iptables/nftables to prevent undesired connections and manually (or with some scripting) crafted /etc/hosts for named hosts to point to those loopbac…

You can see why people like the docker experience, you can manage to do all that in a single interface, instead of one off scripts touching a ton of little things

Re: How Container Filesystem Works: Building a Docker-Like Container from Scratch

#30
post #29

Whenever topic of Docker inner-workings comes up, I am always reminded by this video https://www.youtube.com/watch?v=HPuvDm8IC-4

Absolutely epic. Her career can be divided into two halves, before she did this talk and afterwards. What a crazy thing to do live on stage.
Post reply on HN