Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

435. Containers

This page is for anyone who wants to run containers on KDOS directly: to try another distribution, build an image, or use a tool that expects Docker.

KDOS ships a rootless container engine, Podman: your own account runs containers, with no root daemon. Around it come distrobox for interactive containers that share your home, buildah and skopeo for building and copying images, and two terminal programs that show what is running. The boxes the catalogue’s applications run in are Podman containers too, managed by kdos-box (Boxes); this page is about using the engine directly.

It covers running a container, the subordinate ids and cgroups (the kernel’s control groups, which apply resource limits) a rootless container needs, the storage driver, building images, the Docker API socket that some tools want, and what to check when a container will not start.

Installation

The engine and its tools are ports on the containers shelf:

Port What it installs
podman podman, podman-remote, a docker command that runs podman, the helpers in /usr/lib/podman, and kdos-podman-api
containers-common Everything under /etc/containers, which podman, buildah and skopeo all read
crun The OCI runtime that starts a container’s processes
conmon The monitor process each running container has
netavark, aardvark-dns Container networks and their name server
passt pasta, the user-mode network of a rootless container
slirp4netns The other user-mode network, for a container started with --network slirp4netns
fuse-overlayfs The overlay driver in user space, used on the live medium
catatonit The small init behind --init and a pod’s infra container
distrobox distrobox: containers that share your home and look like part of the host
buildah, skopeo Building images, and inspecting and copying them between registries
podman-tui, lazydocker The two Containers entries in the menu

newuidmap and newgidmap, the setuid helpers that map a range of ids into a rootless container, come from shadow. The base filesystem supplies /etc/subuid and /etc/subgid, and elogind delegates a cgroup subtree to every login’s session.

Every port in the table is on the installation image except podman-tui and lazydocker, which sudo kdos update install <port> adds (see Installing software).

Podman has no daemon, so there is no container service to enable. The API socket that Docker clients use is started on demand by kdos-podman-api, described below.

Configuration

/etc/containers

All four files are written by the containers-common port’s build.sh:

cat > "$PKG/etc/containers/containers.conf" <<'EOF2'
[engine]
cgroup_manager = "cgroupfs"
events_logger = "file"
runtime = "crun"

[network]
network_backend = "netavark"
firewall_driver = "nftables"
default_rootless_network_cmd = "pasta"
EOF2

cat > "$PKG/etc/containers/storage.conf" <<'EOF2'
[storage]
driver = "overlay"

[storage.options.overlay]
mount_program = "/usr/bin/fuse-overlayfs"
EOF2

cat > "$PKG/etc/containers/registries.conf" <<'EOF2'
unqualified-search-registries = ["docker.io"]
EOF2

cat > "$PKG/etc/containers/policy.json" <<'EOF2'
{
    "default": [
        {
            "type": "insecureAcceptAnything"
        }
    ],
    "transports": {
        "docker-daemon": {
            "": [{"type": "insecureAcceptAnything"}]
        }
    }
}
EOF2

ports/core/containers/containers-common/build.sh, lines 14–51

What the four files set:

What each setting means is in Containers.

/etc/subuid and /etc/subgid

Inside a rootless container there are many user ids (root, daemons, users), but outside it they all belong to you. Each account therefore needs a range of subordinate ids that the container’s ids are mapped onto. The base filesystem ships /etc/subuid and /etc/subgid with the same content:

kdos:100000:65536
root:200000:65536

fs/etc/subuid

The installer renames the kdos entries to the account you create. useradd gives a new account a range of its own, as SUB_UID_MIN, SUB_UID_COUNT and their SUB_GID_ counterparts in /etc/login.defs say.

The delegated cgroup

Rootless Podman applies --memory, --cpus and --pids-limit through a cgroup subtree it owns. elogind gives every session one, from fs/etc/elogind/logind.conf.d/50-kdos.conf:

# Each session's cgroup is /sys/fs/cgroup/<session>, with the processes in its
# `session` leaf and a `delegated` subtree the user owns, so rootless podman
# has a subtree in which to apply a box profile's memory, CPU and pids limits.
# Needs the pure cgroup2 mount fstab gives /sys/fs/cgroup and the controllers
# 15_cgroups.sh enables at the root.
DelegateSessionCgroups=yes

fs/etc/elogind/logind.conf.d/50-kdos.conf, lines 30–35

The controllers are enabled at the root by /etc/init.d/15_cgroups.sh at boot. Every login through PAM (the desktop’s, a console’s and the greeter’s alike) is an elogind session with such a subtree. Do not rely on a limit taking effect, though: elogind leaves the session’s cgroup.procs file owned by root, and the kernel refuses to move a process into the delegated subtree without write access to it. The same file is why a box’s memory, cpus and pids are not enforced (Boxes are measured by their processes, and their limits are unenforced). An SSH login opens no PAM session and stays outside every session’s cgroup, where Podman accepts a limit and nothing applies it.

~/.config/containers/storage.conf

Your own store is ~/.local/share/containers/storage, and its run directory is $XDG_RUNTIME_DIR/containers; podman info --format '{{.Store.GraphRoot}}' prints the store’s path.

/etc/containers/storage.conf mounts the store through fuse-overlayfs. The live medium needs that, because its home directory is on the boot overlay and the kernel will not stack an overlay’s writable layer on another overlay. On an installed system, kdos-appbox writes ~/.config/containers/storage.conf naming the kernel’s own, faster overlay driver. It checks each time it runs, and writes the file only when all three hold:

The two drivers record deleted files differently, so once a container exists the driver must not change. See Storage drivers.

kdos-podman-api

Some programs expect a Docker-style API socket. Without systemd there is no socket activation to start one on demand, so the podman port installs a small script, kdos-podman-api. It starts podman system service when nothing answers on your socket, $XDG_RUNTIME_DIR/podman/podman.sock (/run/podman/podman.sock for root), and then runs the command you give it against that socket. The service exits after five minutes with no client:

cat > "$PKG/usr/bin/kdos-podman-api" <<'KDOS_SH'
#!/bin/sh
# kdos-podman-api COMMAND [ARG...] — run COMMAND against this user's Podman
# API socket, starting `podman system service` first if nothing answers on it.
case "$1" in
-h|--help)
	echo "usage: kdos-podman-api COMMAND [ARG...]"
	exit 0
	;;
''|-*)
	echo "usage: kdos-podman-api COMMAND [ARG...]" >&2
	exit 2
	;;
esac
if [ "$(id -u)" = 0 ]; then
	_dir=/run/podman
else
	_dir="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/podman"
fi
_sock="$_dir/podman.sock"
_idle=300

_answers() {
	podman --url "unix://$_sock" version >/dev/null 2>&1
}

if ! _answers; then
	mkdir -p "$_dir" || exit 1
	(
		flock 9
		if ! _answers; then
			rm -f "$_sock"
			env -u CONTAINER_HOST -u CONTAINER_CONNECTION \
				setsid podman system service --time="$_idle" \
				"unix://$_sock" </dev/null >/dev/null 2>&1 9>&- &
			_i=0
			while [ "$_i" -lt 100 ] && ! _answers; do
				sleep 0.1
				_i=$((_i + 1))
			done
		fi
	) 9>"$_dir/.kdos-api.lock"
	_answers || {
		echo "kdos-podman-api: nothing answers on $_sock" >&2
		exit 1
	}
fi

DOCKER_HOST="unix://$_sock"
export DOCKER_HOST
if [ -z "${CONTAINERS_CONF_OVERRIDE:-}" ]; then
	printf '[engine]\nactive_service = "kdos-local"\n\n[engine.service_destinations.kdos-local]\nuri = "unix://%s"\n' \
		"$_sock" > "$_dir/kdos-api.conf.$$"
	mv -f "$_dir/kdos-api.conf.$$" "$_dir/kdos-api.conf"
	CONTAINERS_CONF_OVERRIDE="$_dir/kdos-api.conf"
	export CONTAINERS_CONF_OVERRIDE
fi
exec "$@"
KDOS_SH

ports/core/containers/podman/build.sh, lines 39–97

The Containers menu entry runs podman-tui through it:

cat > "$PKG/usr/share/applications/podman-tui.desktop" <<'EOF'
[Desktop Entry]
Type=Application
Name=Containers
GenericName=Container Manager
Comment=Images, containers, pods and volumes
Exec=kdos-podman-api podman-tui
Icon=network-server
Terminal=true
Categories=System;
Keywords=container;podman;image;pod;box;
EOF

ports/core/containers/podman-tui/build.sh, lines 20–31

Usage

Running a container

  1. Run one, removed again when it exits:

    podman run --rm -it docker.io/library/alpine:latest sh
  2. List what exists, running or not, and the images:

    podman ps -a
    podman images
  3. Stop and remove a container, and remove an image:

    podman stop <name>
    podman rm <name>
    podman rmi <image>

podman ps -a also lists the boxes. Manage those with kdos-box, which keeps their profiles and composed roots in step: removing one with podman rm leaves its profile and its pack mounts behind.

A box’s image is kept when the box is removed, so the box can be made again offline. kdos-box remove <name> --purge runs podman rmi on it when no other box names it, and podman rmi <image> releases one left behind. The kdos/… images belong to kdos app, whose remove releases them.

A distrobox

distrobox makes a container that shares your home directory, your user and the host’s display, so programs in it feel installed:

distrobox create --name dev --image docker.io/library/debian:stable
distrobox enter dev

The first enter sets the container up and prints Container Setup Complete!. Inside, $HOME is /home/<you> and id -un is your own name. distrobox enter dev -- <command> runs one command and returns.

distrobox rm -f dev can wait ten seconds on a container that ignores podman’s stop signal and then report that it could not be stopped; run it again.

The boxes kdos-box create <name> base=image:<ref> makes are distrobox containers, with a profile and the desktop’s launchers; see Boxes.

Building and copying images

podman build -t localhost/mytool -f Containerfile .
buildah bud -t localhost/mytool -f Containerfile .
skopeo inspect docker://docker.io/library/alpine:latest
skopeo copy docker://docker.io/library/alpine:latest oci-archive:alpine.tar

Programs that speak the Docker API

podman-tui, lazydocker and other Docker clients talk to a service over a socket. Run them through kdos-podman-api, which starts the service when it is not running and sets DOCKER_HOST:

kdos-podman-api lazydocker
kdos-podman-api podman-tui

The menu’s Containers and Containers (lazydocker) entries do this.

A login shell already has DOCKER_HOST naming the same socket, set by /etc/profile.d/podman-docker.sh from the podman port. Nothing listens on it, though, unless kdos-podman-api has started the service and the service has not yet exited, so a Docker client run on its own usually finds no socket.

kdos-podman-api gives podman-tui its connection by writing a small containers configuration that names the socket, $XDG_RUNTIME_DIR/podman/kdos-api.conf, and pointing CONTAINERS_CONF_OVERRIDE at it. When you have exported a CONTAINERS_CONF_OVERRIDE of your own, it leaves yours in place and sets only DOCKER_HOST.

Any command works in place of a client, which is the quickest check that the service starts:

kdos-podman-api sh -c 'podman-remote --url "$DOCKER_HOST" version'

Limiting a container

podman run --rm -it --memory 2g --cpus 2 docker.io/library/alpine:latest sh
cat /proc/self/cgroup

Podman accepts the limit, but whether the kernel applies it depends on the container landing in your session’s delegated cgroup, which The delegated cgroup says not to rely on. Check rather than assume: cat /proc/self/cgroup in the container names its cgroup, and cat /sys/fs/cgroup/memory.max there prints 2147483648 only when the 2 GB limit is in force. A shell on the host that prints 0::/ is in no session, and a --memory container started from it has no memory.max file at all.

On the live medium and on an installed system

On the live medium the store is on the overlay in RAM, goes through fuse-overlayfs, and is gone at power-off unless the medium has a persistence store (Live persistence). On an installed system the store is on disk, and uses the kernel’s overlay driver once kdos-appbox has written your storage.conf.

Tips

Troubleshooting

Start with kdos doctor (Diagnostics), run as your own account. Its Containers section checks that the mount namespace’s root is /, that /etc/subuid and /etc/subgid carry your range, and that podman info can open your store; its Desktop section checks the setuid bits on newuidmap and newgidmap. On a healthy machine:

Containers
  [ ok ] mount namespace root is /
  [ ok ] subuid mapping present
  [ ok ] subgid mapping present
  [ ok ] podman store /home/<you>/.local/share/containers/storage

When podman info fails, the line is a [warn] that carries podman’s own first line of error.

Error: creating runtime static files directory "/var/lib/containers/storage/libpod": mkdir /var/lib/containers/storage: permission denied
Rootless Podman is using root’s store, because a storage.conf it reads names graphroot or runroot. podman info --format '{{.Store.GraphRoot}}' should print a path under your home. /etc/containers/storage.conf as shipped names neither; remove the two lines from it, or from ~/.config/containers/storage.conf. kdos doctor shows the same error on its podman info fails line.
Every container fails, the engine exits 125
newuidmap or newgidmap has lost its setuid bit: sudo chmod 4755 /usr/bin/newuidmap /usr/bin/newgidmap.
no subuid ranges found for user
Your account has no line in /etc/subuid or /etc/subgid. Read both files, pick a range that overlaps no other account’s (the example assumes nothing uses 300000 to 365535), add it, then run podman system migrate:
sudo usermod --add-subuids 300000-365535 --add-subgids 300000-365535 "$USER"
podman system migrate
A container fails to mount its root on the live medium
A ~/.config/containers/storage.conf names the kernel’s overlay driver, which cannot stack on the boot overlay. Move the file aside, and the system file’s fuse-overlayfs setting applies. Containers made under the other driver cannot be used with this one.
A --memory or --cpus limit has no effect
Podman could not place the container in your session’s delegated cgroup, so nothing enforces the limit; see The delegated cgroup. From an SSH login, or any shell where cat /proc/self/cgroup prints 0::/, no limit can apply at all.
podman-tui or lazydocker shows nothing
Run it through kdos-podman-api, which starts the API service. When that fails it says nothing answers on <socket>; run podman system service --time=0 in a terminal to see why.
An image pull refuses to start
/etc/containers/policy.json is missing; reinstall containers-common with sudo kpkg install -f containers-common (see kpkg).

Known gaps

See also