Skip to content
Systems Programming 5 min read

Principles of a Daemonless Runtime: Why Cardinal Requires No Background Service

Why a daemonless runtime is superior for lean container workloads: direct clone(2) execution, cgroups v2 resource accounting, OverlayFS, and zero idle memory footprint.

#Linux #Go #Containers #Namespaces #OverlayFS #cgroups v2
Key Architectural Takeaways
  • ▸Traditional runtimes consume host memory on persistent root daemon daemons (dockerd / containerd).
  • ▸Cardinal configures namespaces, mounts OverlayFS, binds cgroups v2 controllers, and cleanly exits.
  • ▸Containers continue execution under the supervision of the Linux kernel directly.
  • ▸Dynamic port assignment (`cardinal port add/rm`) modifies nftables/iptables without container restarts.

1. The Overhead of Persistent Runtime Daemons

In classical container systems like Docker or containerd, a persistent background daemon consumes 50-150 MB of resident RAM even when idle. Daemon crashes endanger state tracking and active workloads. Cardinal was engineered from first principles around a daemonless philosophy: a static ~5 MB binary runs only when executing, stopping, or inspecting containers.

2. Linux Primitives: clone(2) & cgroups v2

Linux containers are standard processes isolated via kernel namespaces. Cardinal invokes clone(2) with CLONE_NEWPID, CLONE_NEWNS, CLONE_NEWNET, CLONE_NEWUTS, and CLONE_NEWIPC flags. Resource constraints (CPU quotas, memory.max, and I/O weights) are enforced directly through native cgroups v2 controllers (`/sys/fs/cgroup/cardinal/<id>`).

Пример ограничения ресурсов в Cardinal CLI
bash
# Запуск PostgreSQL с лимитом 1 ГБ RAM и 2 ядрами CPU
cardinal run -d --name pg-main \
  --memory 1024m \
  --cpus 2 \
  -p 5432:5432 \
  postgres:16

# Проверка реального потребления ресурсов через cgroups v2:
cardinal stats pg-main

3. Dynamic Port Forwarding Without Restarts

A distinct feature of Cardinal is dynamic port forwarding on running workloads without recreation. The command `cardinal port add <container> <host_port>:<container_port>` modifies Linux network NAT tables on the fly, immediately routing incoming packets.

animesao.work.gd Website · MIT

MIT LicensePermissive

The source code of the animesao.work.gd website (Nuxt 4, Vue 3, Tailwind CSS 4), architecture schematics, and engineering notes are open-source under the MIT License. Commercial and private use, modification, and reproduction are permitted with copyright attribution.

Permissions
  • ✓Commercial use
  • ✓Modification
  • ✓Distribution
  • ✓Private use
Limitations
  • ✕No liability
  • ✕No warranty
Conditions
  • ℹCopyright and license notice (c) 2026 animesao
Full License TextSPDX: MIT
MIT License

Copyright (c) 2026 animesao

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.