[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7CTMN55BJVRJ62915YK5S35":3,"skill-same:01M7CTMN55BJVRJ62915YK5S35":58},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":38,"commitSha":39,"skillDirectory":40,"forksCount":13,"repositoryHtmlUrl":41,"repositoryHomepageUrl":6,"ownerHtmlUrl":42,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":43,"install":44,"resources":57},"01M7CTMN55BJVRJ62915YK5S35","anara-s6-container-supervision",null,"Modify or debug s6 services in the Anara Docker image.","dwikanugraha13\u002FProject-Anara","dwikanugraha13","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F63535036?v=4","01M7CTBN0DG8GDNP4QZ68W8M0A","01M7CTBN10Q015JDBYJS6AJRGN",0,"MIT","https:\u002F\u002Fgithub.com\u002Fdwikanugraha13\u002FProject-Anara\u002Fblob\u002Fmain\u002Fbackend\u002Foptional-skills\u002Fdevops\u002Fanara-s6-container-supervision\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: anara-s6-container-supervision\ndescription: Modify or debug s6 services in the Anara Docker image.\nversion: 1.0.0\nauthor: Anara Agent\nlicense: MIT\nplatforms: [linux]\nenvironments: [s6]\nmetadata:\n  anara:\n    tags: [docker, s6, supervision, gateway, profiles]\n    related_skills: [anara-agent]\n---\n\n# Anara s6-overlay Container Supervision\n\n## When to use this skill\n\nLoad this skill when you're working on:\n- Adding or removing a static service in the Anara Docker image (something that should be supervised at every container start, like the dashboard)\n- Diagnosing why a per-profile gateway isn't starting, restarting, or surviving `docker restart`\n- Understanding why the container's CMD is `\u002Fopt\u002Fanara\u002Fdocker\u002Fmain-wrapper.sh` and how leading-dash args reach the user's program\n- Modifying `cont-init.d` boot scripts (UID remap, volume seeding, profile reconciliation)\n- Changing the rendered run-script for per-profile gateways (Phase 4)\n\nIf you're just running the Anara Agent and want to use Docker, see `website\u002Fdocs\u002Fuser-guide\u002Fdocker.md` instead.\n\n## Architecture at a glance\n\n```\n\u002Finit                                  ← PID 1 (s6-overlay v3.2.3.0)\n├── cont-init.d                        ← oneshot setup, runs as root\n│   ├── 01-anara-setup                ← docker\u002Fstage2-hook.sh\n│   │   ├── UID\u002FGID remap\n│   │   ├── chown \u002Fopt\u002Fdata\n│   │   ├── chown \u002Fopt\u002Fdata\u002Fprofiles (every boot)\n│   │   ├── seed .env \u002F config.yaml \u002F SOUL.md\n│   │   └── skills_sync.py\n│   └── 02-reconcile-profiles          ← anara_cli.container_boot\n│       ├── chown \u002Frun\u002Fservice (anara-writable for runtime register)\n│       └── walk $ANARA_HOME\u002Fprofiles\u002F\u003Cname>\u002Fgateway_state.json\n│           → recreate \u002Frun\u002Fservice\u002Fgateway-\u003Cname>\u002F\n│           → auto-start only those with prior_state == \"running\"\n│\n├── s6-rc.d (static services, in \u002Fetc\u002Fs6-overlay\u002Fs6-rc.d\u002F)\n│   ├── main-anara\u002Frun                ← exec sleep infinity (no-op slot)\n│   └── dashboard\u002Frun                  ← if ANARA_DASHBOARD=1, runs `anara dashboard`\n│\n├── \u002Frun\u002Fservice (s6-svscan watches; tmpfs)\n│   ├── gateway-coder\u002F                 ← runtime-registered per-profile\n│   │   ├── type        (\"longrun\")\n│   │   ├── run         (\"#!\u002Fcommand\u002Fwith-contenv sh ... exec s6-setuidgid anara anara -p coder gateway run\")\n│   │   ├── down        (marker — present means \"registered but don't auto-start\")\n│   │   └── log\u002Frun     (s6-log → $ANARA_HOME\u002Flogs\u002Fgateways\u002Fcoder\u002Fcurrent)\n│   └── ...\n│\n└── CMD (\"main program\")               ← \u002Fopt\u002Fanara\u002Fdocker\u002Fmain-wrapper.sh\n    └── routes user args: bare exec | anara subcommand | anara (no args)\n        — exec'd by \u002Finit with stdin\u002Fstdout\u002Fstderr inherited (TTY for --tui)\n```\n\n## Key files\n\n| Path | Role |\n|---|---|\n| `Dockerfile` | s6-overlay install + cont-init.d wiring + `ENTRYPOINT [\"\u002Fopt\u002Fanara\u002Fdocker\u002Fentrypoint-dispatch.sh\"]` |\n| `docker\u002Fentrypoint-dispatch.sh` | PID-1 dispatcher: exec's `\u002Finit` + main-wrapper when the image owns PID 1; on wrapped runtimes (Fly Machines, `docker run --init`) falls back to stage2-hook + main-wrapper directly, restoring the s6 helper PATH first (#38349). |\n| `docker\u002Fstage2-hook.sh` | The \"old entrypoint logic\" — UID remap, chown, seed, skills sync. Runs as cont-init.d\u002F01-anara-setup. |\n| `docker\u002Fcont-init.d\u002F02-reconcile-profiles` | Calls `anara_cli.container_boot` on every boot to restore profile gateway slots from the persistent volume. |\n| `docker\u002Fmain-wrapper.sh` | The container's CMD. Routes user args, drops to anara via `s6-setuidgid`, exec's the chosen program. |\n| `docker\u002Fs6-rc.d\u002Fmain-anara\u002Frun` | No-op `sleep infinity` — slot exists so the s6-rc user bundle is valid; main anara runs as the CMD, not as a supervised service. |\n| `docker\u002Fs6-rc.d\u002Fdashboard\u002Frun` | Conditional service — `exec sleep infinity` unless `ANARA_DASHBOARD` is truthy. |\n| `docker\u002Fentrypoint.sh` | Back-compat shim that `exec`s the stage2 hook. External scripts that hard-coded the old entrypoint path still work. |\n| `anara_cli\u002Fservice_manager.py` | `S6ServiceManager`: `register_profile_gateway`, `unregister_profile_gateway`, `start\u002Fstop\u002Frestart\u002Fis_running`, `list_profile_gateways`. |\n| `anara_cli\u002Fcontainer_boot.py` | `reconcile_profile_gateways()` — walks persistent profiles, regenerates s6 slots, emits `container-boot.log`. |\n| `anara_cli\u002Fgateway.py::_dispatch_via_service_manager_if_s6` | Intercepts `anara gateway start\u002Fstop\u002Frestart` and routes to s6 when running in a container. |\n\n## Why Architecture B (CMD as main program, not s6-supervised)\n\nThe original plan (v1–v3) called for main anara to run as a supervised s6-rc service. Two real s6-overlay v3 mechanics blocked that:\n\n1. **cont-init.d scripts receive no CMD args** — so the stage2 hook can't parse `docker run \u003Cimage> chat -q \"hi\"` to set `ANARA_ARGS` for a service `run` script to consume.\n2. **`\u002Frun\u002Fs6\u002Fbasedir\u002Fbin\u002Fhalt` does NOT propagate the exit code** written to `\u002Frun\u002Fs6-linux-init-container-results\u002Fexitcode`. Containers always exit 143 (SIGTERM) regardless. Confirmed by skarnet (s6 author) in [issue #477](https:\u002F\u002Fgithub.com\u002Fjust-containers\u002Fs6-overlay\u002Fissues\u002F477): _\"if you want a container shutdown, you need to either have your CMD exit, or, if you have no CMD, write the container exit code you want then call halt\"_.\n\nSo we use the s6-overlay-native CMD pattern via the dispatcher: `ENTRYPOINT [\"\u002Fopt\u002Fanara\u002Fdocker\u002Fentrypoint-dispatch.sh\"]`, which under PID 1 exec's `\u002Finit \u002Fopt\u002Fanara\u002Fdocker\u002Fmain-wrapper.sh \"$@\"`. The wrapper is prepended to user args automatically — so `docker run \u003Cimage> --version` becomes `\u002Finit main-wrapper.sh --version`, and `--version` doesn't get intercepted by \u002Finit's POSIX shell. The wrapper drops to anara via `s6-setuidgid`, then exec's the chosen program. The program's exit code becomes the container exit code, exactly matching the pre-s6 tini contract. When the entrypoint is NOT PID 1 (Fly Machines, `docker run --init`), the dispatcher skips `\u002Finit` entirely (it would abort with `can only run as pid 1`), restores the s6 helper PATH, runs stage2-hook.sh, and exec's main-wrapper.sh directly — no supervised services on that path (#38349).\n\nTrade-off: main anara is unsupervised under s6. That exactly matches its behavior under tini (the pre-s6 image). Dashboard supervision is the only **new** guarantee — and per-profile gateways under `\u002Frun\u002Fservice\u002F` get full supervision.\n\n## Quick recipes\n\n### Verify s6 is PID 1 in a running container\n\n```sh\ndocker exec \u003Cc> sh -c 'cat \u002Fproc\u002F1\u002Fcomm; readlink \u002Fproc\u002F1\u002Fexe'\n# Expect: s6-svscan or init \u002F \u002Fpackage\u002Fadmin\u002Fs6\u002F...\u002Fs6-svscan\n```\n\n### Inspect a profile gateway service\n\n```sh\n# \u002Fcommand\u002F isn't on docker-exec PATH — use absolute path\ndocker exec \u003Cc> \u002Fcommand\u002Fs6-svstat \u002Frun\u002Fservice\u002Fgateway-\u003Cname>\n# \"up (pid …) … seconds\"            → running\n# \"down (exitcode N) … seconds, normally up, want up, …\" → s6 wants it up but the process keeps exiting (crash loop)\n# \"down … normally up, ready …\"     → user stopped it\n```\n\n### Bring a service up\u002Fdown manually\n\n```sh\ndocker exec \u003Cc> \u002Fcommand\u002Fs6-svc -u \u002Frun\u002Fservice\u002Fgateway-\u003Cname>   # up\ndocker exec \u003Cc> \u002Fcommand\u002Fs6-svc -d \u002Frun\u002Fservice\u002Fgateway-\u003Cname>   # down\ndocker exec \u003Cc> \u002Fcommand\u002Fs6-svc -t \u002Frun\u002Fservice\u002Fgateway-\u003Cname>   # SIGTERM (restart)\n```\n\n### Watch the cont-init reconciler log\n\n```sh\ndocker exec \u003Cc> tail -n 50 \u002Fopt\u002Fdata\u002Flogs\u002Fcontainer-boot.log\n# 2026-05-21T06:18:05+0000 profile=coder prior_state=running action=started\n# 2026-05-21T06:18:05+0000 profile=writer prior_state=stopped action=registered\n```\n\n### Add a new static service\n\n1. Create `docker\u002Fs6-rc.d\u002F\u003Cname>\u002Ftype` with `longrun\\n` and `docker\u002Fs6-rc.d\u002F\u003Cname>\u002Frun` (use `#!\u002Fcommand\u002Fwith-contenv sh` + `# shellcheck shell=sh`).\n2. Drop to anara via `s6-setuidgid anara` at the top of run (unless you specifically need root).\n3. Create empty `docker\u002Fs6-rc.d\u002F\u003Cname>\u002Fdependencies.d\u002Fbase` so it waits for the base bundle.\n4. Create empty `docker\u002Fs6-rc.d\u002Fuser\u002Fcontents.d\u002F\u003Cname>` so it joins the user bundle.\n5. The `COPY docker\u002Fs6-rc.d\u002F` in the Dockerfile picks it up automatically — no other changes.\n\n### Change the per-profile gateway run command\n\nEdit `S6ServiceManager._render_run_script` in `anara_cli\u002Fservice_manager.py`. The function is also called by `anara_cli\u002Fcontainer_boot.py::_register_service` during boot reconciliation, so it's the single source of truth. Update the corresponding assertion in `tests\u002Fanara_cli\u002Ftest_service_manager.py::test_s6_register_creates_service_dir_and_triggers_scan`.\n\n### Run the docker test harness\n\n```sh\ndocker build -t anara-agent-harness:latest .\nANARA_TEST_IMAGE=anara-agent-harness:latest scripts\u002Frun_tests.sh tests\u002Fdocker\u002F -v\n# Expect 19 passed, 0 xfailed against the s6 image\n```\n\nThe harness lives in `tests\u002Fdocker\u002F` and skips when Docker isn't available. The per-test timeout is bumped to 180s (see `tests\u002Fdocker\u002Fconftest.py`).\n\n## Common pitfalls\n\n### \"command not found\" via `docker exec`\n\n`\u002Fcommand\u002F` (where s6-overlay puts its binaries) is on PATH only for processes spawned by the supervision tree — services, cont-init.d, main-wrapper.sh. `docker exec \u003Cc> s6-svstat …` will fail with \"command not found\"; always use the absolute path `\u002Fcommand\u002Fs6-svstat`. The `anara` binary works because the Dockerfile adds `\u002Fopt\u002Fanara\u002F.venv\u002Fbin` to the runtime `ENV PATH`.\n\n### Profile directory ownership\n\nThe cont-init reconciler runs as anara (`s6-setuidgid anara` in `02-reconcile-profiles`). If a profile dir ends up root-owned (e.g. because `docker exec \u003Cc> anara profile create …` ran as root by default), the reconciler can't read SOUL.md and fails with `PermissionError`. Mitigation: `stage2-hook.sh` chowns `$ANARA_HOME\u002Fprofiles` to anara on **every** boot, idempotently. Don't remove that block.\n\n### Files written by `docker exec` are root-owned\n\n`docker exec` defaults to root. Either pass `--user anara` or rely on the stage2 chown sweep next reboot. Don't write files under `$ANARA_HOME\u002Fprofiles\u002F\u003Cname>\u002F` as root manually — the next reconcile pass will sweep them but in-flight operations may hit perm errors.\n\n### Service slot exists but s6-svstat says \"s6-supervise not running\"\n\nThe service directory is on tmpfs and was wiped on container restart. Either the cont-init reconciler hasn't run yet (give it a moment after `docker restart`) or it failed. Check `docker logs \u003Cc> | grep '02-reconcile'`.\n\n### Gateway starts then immediately exits (`down (exitcode 1)` in svstat)\n\nMost likely the profile has no model or auth configured. The service slot is correct — the gateway itself is unconfigured. Run `anara -p \u003Cprofile> setup` first. The s6 supervisor will keep restarting it; that's the desired behavior (when you fix the config, the next attempt succeeds and stays up).\n\n### Reconciler skipped a profile\n\nThe reconciler keys on the **presence of `SOUL.md`** as the \"real profile\" marker. `anara profile create` always seeds it. If a profile dir is missing SOUL.md (stray directory, partial restore, backup-in-progress), the reconciler skips it intentionally. Add a `SOUL.md` (even empty) to opt back in.\n\n### \"Help, the container exits 143!\"\n\nCheck whether something is invoking `s6-svscanctl -t` or `\u002Frun\u002Fs6\u002Fbasedir\u002Fbin\u002Fhalt` — both cause \u002Finit to begin stage 3 shutdown but return 143 (SIGTERM) rather than the desired exit code. This was the Phase 2 architecture pivot from A to B. For container shutdown with a real exit code, you must let the CMD (main-wrapper.sh) exit normally; do **not** try to control exit from a finish script.\n\n## Related skills\n\n- `anara-agent-dev`: General anara-agent codebase navigation\n- `anara-tool-quirks`: Specific Anara-tool workarounds (sed\u002Fgrep\u002Fetc.) — load when debugging the s6 stack's interaction with anara built-in tools.\n","# Anara s6-overlay Container Supervision\n\n## When to use this skill\n\nLoad this skill when you're working on:\n- Adding or removing a static service in the Anara Docker image (something that should be supervised at every container start, like the dashboard)\n- Diagnosing why a per-profile gateway isn't starting, restarting, or surviving `docker restart`\n- Understanding why the container's CMD is `\u002Fopt\u002Fanara\u002Fdocker\u002Fmain-wrapper.sh` and how leading-dash args reach the user's program\n- Modifying `cont-init.d` boot scripts (UID remap, volume seeding, profile reconciliation)\n- Changing the rendered run-script for per-profile gateways (Phase 4)\n\nIf you're just running the Anara Agent and want to use Docker, see `website\u002Fdocs\u002Fuser-guide\u002Fdocker.md` instead.\n\n## Architecture at a glance\n\n```\n\u002Finit                                  ← PID 1 (s6-overlay v3.2.3.0)\n├── cont-init.d                        ← oneshot setup, runs as root\n│   ├── 01-anara-setup                ← docker\u002Fstage2-hook.sh\n│   │   ├── UID\u002FGID remap\n│   │   ├── chown \u002Fopt\u002Fdata\n│   │   ├── chown \u002Fopt\u002Fdata\u002Fprofiles (every boot)\n│   │   ├── seed .env \u002F config.yaml \u002F SOUL.md\n│   │   └── skills_sync.py\n│   └── 02-reconcile-profiles          ← anara_cli.container_boot\n│       ├── chown \u002Frun\u002Fservice (anara-writable for runtime register)\n│       └── walk $ANARA_HOME\u002Fprofiles\u002F\u003Cname>\u002Fgateway_state.json\n│           → recreate \u002Frun\u002Fservice\u002Fgateway-\u003Cname>\u002F\n│           → auto-start only those with prior_state == \"running\"\n│\n├── s6-rc.d (static services, in \u002Fetc\u002Fs6-overlay\u002Fs6-rc.d\u002F)\n│   ├── main-anara\u002Frun                ← exec sleep infinity (no-op slot)\n│   └── dashboard\u002Frun                  ← if ANARA_DASHBOARD=1, runs `anara dashboard`\n│\n├── \u002Frun\u002Fservice (s6-svscan watches; tmpfs)\n│   ├── gateway-coder\u002F                 ← runtime-registered per-profile\n│   │   ├── type        (\"longrun\")\n│   │   ├── run         (\"#!\u002Fcommand\u002Fwith-contenv sh ... exec s6-setuidgid anara anara -p coder gateway run\")\n│   │   ├── down        (marker — present means \"registered but don't auto-start\")\n│   │   └── log\u002Frun     (s6-log → $ANARA_HOME\u002Flogs\u002Fgateways\u002Fcoder\u002Fcurrent)\n│   └── ...\n│\n└── CMD (\"main program\")               ← \u002Fopt\u002Fanara\u002Fdocker\u002Fmain-wrapper.sh\n    └── routes user args: bare exec | anara subcommand | anara (no args)\n        — exec'd by \u002Finit with stdin\u002Fstdout\u002Fstderr inherited (TTY for --tui)\n```\n\n## Key files\n\n| Path | Role |\n|---|---|\n| `Dockerfile` | s6-overlay install + cont-init.d wiring + `ENTRYPOINT [\"\u002Fopt\u002Fanara\u002Fdocker\u002Fentrypoint-dispatch.sh\"]` |\n| `docker\u002Fentrypoint-dispatch.sh` | PID-1 dispatcher: exec's `\u002Finit` + main-wrapper when the image owns PID 1; on wrapped runtimes (Fly Machines, `docker run --init`) falls back to stage2-hook + main-wrapper directly, restoring the s6 helper PATH first (#38349). |\n| `docker\u002Fstage2-hook.sh` | The \"old entrypoint logic\" — UID remap, chown, seed, skills sync. Runs as cont-init.d\u002F01-anara-setup. |\n| `docker\u002Fcont-init.d\u002F02-reconcile-profiles` | Calls `anara_cli.container_boot` on every boot to restore profile gateway slots from the persistent volume. |\n| `docker\u002Fmain-wrapper.sh` | The container's CMD. Routes user args, drops to anara via `s6-setuidgid`, exec's the chosen program. |\n| `docker\u002Fs6-rc.d\u002Fmain-anara\u002Frun` | No-op `sleep infinity` — slot exists so the s6-rc user bundle is valid; main anara runs as the CMD, not as a supervised service. |\n| `docker\u002Fs6-rc.d\u002Fdashboard\u002Frun` | Conditional service — `exec sleep infinity` unless `ANARA_DASHBOARD` is truthy. |\n| `docker\u002Fentrypoint.sh` | Back-compat shim that `exec`s the stage2 hook. External scripts that hard-coded the old entrypoint path still work. |\n| `anara_cli\u002Fservice_manager.py` | `S6ServiceManager`: `register_profile_gateway`, `unregister_profile_gateway`, `start\u002Fstop\u002Frestart\u002Fis_running`, `list_profile_gateways`. |\n| `anara_cli\u002Fcontainer_boot.py` | `reconcile_profile_gateways()` — walks persistent profiles, regenerates s6 slots, emits `container-boot.log`. |\n| `anara_cli\u002Fgateway.py::_dispatch_via_service_manager_if_s6` | Intercepts `anara gateway start\u002Fstop\u002Frestart` and routes to s6 when running in a container. |\n\n## Why Architecture B (CMD as main program, not s6-supervised)\n\nThe original plan (v1–v3) called for main anara to run as a supervised s6-rc service. Two real s6-overlay v3 mechanics blocked that:\n\n1. **cont-init.d scripts receive no CMD args** — so the stage2 hook can't parse `docker run \u003Cimage> chat -q \"hi\"` to set `ANARA_ARGS` for a service `run` script to consume.\n2. **`\u002Frun\u002Fs6\u002Fbasedir\u002Fbin\u002Fhalt` does NOT propagate the exit code** written to `\u002Frun\u002Fs6-linux-init-container-results\u002Fexitcode`. Containers always exit 143 (SIGTERM) regardless. Confirmed by skarnet (s6 author) in [issue #477](https:\u002F\u002Fgithub.com\u002Fjust-containers\u002Fs6-overlay\u002Fissues\u002F477): _\"if you want a container shutdown, you need to either have your CMD exit, or, if you have no CMD, write the container exit code you want then call halt\"_.\n\nSo we use the s6-overlay-native CMD pattern via the dispatcher: `ENTRYPOINT [\"\u002Fopt\u002Fanara\u002Fdocker\u002Fentrypoint-dispatch.sh\"]`, which under PID 1 exec's `\u002Finit \u002Fopt\u002Fanara\u002Fdocker\u002Fmain-wrapper.sh \"$@\"`. The wrapper is prepended to user args automatically — so `docker run \u003Cimage> --version` becomes `\u002Finit main-wrapper.sh --version`, and `--version` doesn't get intercepted by \u002Finit's POSIX shell. The wrapper drops to anara via `s6-setuidgid`, then exec's the chosen program. The program's exit code becomes the container exit code, exactly matching the pre-s6 tini contract. When the entrypoint is NOT PID 1 (Fly Machines, `docker run --init`), the dispatcher skips `\u002Finit` entirely (it would abort with `can only run as pid 1`), restores the s6 helper PATH, runs stage2-hook.sh, and exec's main-wrapper.sh directly — no supervised services on that path (#38349).\n\nTrade-off: main anara is unsupervised under s6. That exactly matches its behavior under tini (the pre-s6 image). Dashboard supervision is the only **new** guarantee — and per-profile gateways under `\u002Frun\u002Fservice\u002F` get full supervision.\n\n## Quick recipes\n\n### Verify s6 is PID 1 in a running container\n\n```sh\ndocker exec \u003Cc> sh -c 'cat \u002Fproc\u002F1\u002Fcomm; readlink \u002Fproc\u002F1\u002Fexe'\n# Expect: s6-svscan or init \u002F \u002Fpackage\u002Fadmin\u002Fs6\u002F...\u002Fs6-svscan\n```\n\n### Inspect a profile gateway service\n\n```sh\n# \u002Fcommand\u002F isn't on docker-exec PATH — use absolute path\ndocker exec \u003Cc> \u002Fcommand\u002Fs6-svstat \u002Frun\u002Fservice\u002Fgateway-\u003Cname>\n# \"up (pid …) … seconds\"            → running\n# \"down (exitcode N) … seconds, normally up, want up, …\" → s6 wants it up but the process keeps exiting (crash loop)\n# \"down … normally up, ready …\"     → user stopped it\n```\n\n### Bring a service up\u002Fdown manually\n\n```sh\ndocker exec \u003Cc> \u002Fcommand\u002Fs6-svc -u \u002Frun\u002Fservice\u002Fgateway-\u003Cname>   # up\ndocker exec \u003Cc> \u002Fcommand\u002Fs6-svc -d \u002Frun\u002Fservice\u002Fgateway-\u003Cname>   # down\ndocker exec \u003Cc> \u002Fcommand\u002Fs6-svc -t \u002Frun\u002Fservice\u002Fgateway-\u003Cname>   # SIGTERM (restart)\n```\n\n### Watch the cont-init reconciler log\n\n```sh\ndocker exec \u003Cc> tail -n 50 \u002Fopt\u002Fdata\u002Flogs\u002Fcontainer-boot.log\n# 2026-05-21T06:18:05+0000 profile=coder prior_state=running action=started\n# 2026-05-21T06:18:05+0000 profile=writer prior_state=stopped action=registered\n```\n\n### Add a new static service\n\n1. Create `docker\u002Fs6-rc.d\u002F\u003Cname>\u002Ftype` with `longrun\\n` and `docker\u002Fs6-rc.d\u002F\u003Cname>\u002Frun` (use `#!\u002Fcommand\u002Fwith-contenv sh` + `# shellcheck shell=sh`).\n2. Drop to anara via `s6-setuidgid anara` at the top of run (unless you specifically need root).\n3. Create empty `docker\u002Fs6-rc.d\u002F\u003Cname>\u002Fdependencies.d\u002Fbase` so it waits for the base bundle.\n4. Create empty `docker\u002Fs6-rc.d\u002Fuser\u002Fcontents.d\u002F\u003Cname>` so it joins the user bundle.\n5. The `COPY docker\u002Fs6-rc.d\u002F` in the Dockerfile picks it up automatically — no other changes.\n\n### Change the per-profile gateway run command\n\nEdit `S6ServiceManager._render_run_script` in `anara_cli\u002Fservice_manager.py`. The function is also called by `anara_cli\u002Fcontainer_boot.py::_register_service` during boot reconciliation, so it's the single source of truth. Update the corresponding assertion in `tests\u002Fanara_cli\u002Ftest_service_manager.py::test_s6_register_creates_service_dir_and_triggers_scan`.\n\n### Run the docker test harness\n\n```sh\ndocker build -t anara-agent-harness:latest .\nANARA_TEST_IMAGE=anara-agent-harness:latest scripts\u002Frun_tests.sh tests\u002Fdocker\u002F -v\n# Expect 19 passed, 0 xfailed against the s6 image\n```\n\nThe harness lives in `tests\u002Fdocker\u002F` and skips when Docker isn't available. The per-test timeout is bumped to 180s (see `tests\u002Fdocker\u002Fconftest.py`).\n\n## Common pitfalls\n\n### \"command not found\" via `docker exec`\n\n`\u002Fcommand\u002F` (where s6-overlay puts its binaries) is on PATH only for processes spawned by the supervision tree — services, cont-init.d, main-wrapper.sh. `docker exec \u003Cc> s6-svstat …` will fail with \"command not found\"; always use the absolute path `\u002Fcommand\u002Fs6-svstat`. The `anara` binary works because the Dockerfile adds `\u002Fopt\u002Fanara\u002F.venv\u002Fbin` to the runtime `ENV PATH`.\n\n### Profile directory ownership\n\nThe cont-init reconciler runs as anara (`s6-setuidgid anara` in `02-reconcile-profiles`). If a profile dir ends up root-owned (e.g. because `docker exec \u003Cc> anara profile create …` ran as root by default), the reconciler can't read SOUL.md and fails with `PermissionError`. Mitigation: `stage2-hook.sh` chowns `$ANARA_HOME\u002Fprofiles` to anara on **every** boot, idempotently. Don't remove that block.\n\n### Files written by `docker exec` are root-owned\n\n`docker exec` defaults to root. Either pass `--user anara` or rely on the stage2 chown sweep next reboot. Don't write files under `$ANARA_HOME\u002Fprofiles\u002F\u003Cname>\u002F` as root manually — the next reconcile pass will sweep them but in-flight operations may hit perm errors.\n\n### Service slot exists but s6-svstat says \"s6-supervise not running\"\n\nThe service directory is on tmpfs and was wiped on container restart. Either the cont-init reconciler hasn't run yet (give it a moment after `docker restart`) or it failed. Check `docker logs \u003Cc> | grep '02-reconcile'`.\n\n### Gateway starts then immediately exits (`down (exitcode 1)` in svstat)\n\nMost likely the profile has no model or auth configured. The service slot is correct — the gateway itself is unconfigured. Run `anara -p \u003Cprofile> setup` first. The s6 supervisor will keep restarting it; that's the desired behavior (when you fix the config, the next attempt succeeds and stays up).\n\n### Reconciler skipped a profile\n\nThe reconciler keys on the **presence of `SOUL.md`** as the \"real profile\" marker. `anara profile create` always seeds it. If a profile dir is missing SOUL.md (stray directory, partial restore, backup-in-progress), the reconciler skips it intentionally. Add a `SOUL.md` (even empty) to opt back in.\n\n### \"Help, the container exits 143!\"\n\nCheck whether something is invoking `s6-svscanctl -t` or `\u002Frun\u002Fs6\u002Fbasedir\u002Fbin\u002Fhalt` — both cause \u002Finit to begin stage 3 shutdown but return 143 (SIGTERM) rather than the desired exit code. This was the Phase 2 architecture pivot from A to B. For container shutdown with a real exit code, you must let the CMD (main-wrapper.sh) exit normally; do **not** try to control exit from a finish script.\n\n## Related skills\n\n- `anara-agent-dev`: General anara-agent codebase navigation\n- `anara-tool-quirks`: Specific Anara-tool workarounds (sed\u002Fgrep\u002Fetc.) — load when debugging the s6 stack's interaction with anara built-in tools.\n",{"name":5,"author":23,"license":14,"version":24,"metadata":25,"platforms":35,"description":7,"environments":37},"Anara Agent","1.0.0",{"anara":26},{"tags":27,"related_skills":33},[28,29,30,31,32],"docker","s6","supervision","gateway","profiles",[34],"anara-agent",[36],"linux",[29],"main","3e6d6b7ffb6ab43ddf3991509e5cfb5f8c90cd1a","backend\u002Foptional-skills\u002Fdevops\u002Fanara-s6-container-supervision","https:\u002F\u002Fgithub.com\u002Fdwikanugraha13\u002FProject-Anara","https:\u002F\u002Fgithub.com\u002Fdwikanugraha13","2026-10-13 07:57:21",{"source":8,"skillName":5,"commands":45,"prompt":55,"zipAvailable":56},[46,49,52],{"tool":47,"command":48},"npx","npx skills add dwikanugraha13\u002FProject-Anara --skill anara-s6-container-supervision",{"tool":50,"command":51},"bunx","bunx skills add dwikanugraha13\u002FProject-Anara --skill anara-s6-container-supervision",{"tool":53,"command":54},"pnpm","pnpm dlx skills add dwikanugraha13\u002FProject-Anara --skill anara-s6-container-supervision","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fdwikanugraha13\u002FProject-Anara\u002Fblob\u002Fmain\u002Fbackend\u002Foptional-skills\u002Fdevops\u002Fanara-s6-container-supervision\u002FSKILL.md",true,[],[59,66,73,81,88,95],{"skillNo":60,"name":61,"nameZh":6,"description":62,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":63,"categories":64,"keywords":65,"publishedAt":18},"01M7CVK8W5MPQ8H45A6XE6RPK1","youtube-content","YouTube transcripts to summaries, threads, blogs.","https:\u002F\u002Fgithub.com\u002Fdwikanugraha13\u002FProject-Anara\u002Fblob\u002Fmain\u002Fbackend\u002Fskills\u002Fyoutube-content\u002FSKILL.md",[],[],{"skillNo":67,"name":68,"nameZh":6,"description":69,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":70,"categories":71,"keywords":72,"publishedAt":18},"01M7CVK56KG9399ZZVE9KM54WS","xurl","X\u002FTwitter via xurl CLI: raw post search, posting, DM, media.","https:\u002F\u002Fgithub.com\u002Fdwikanugraha13\u002FProject-Anara\u002Fblob\u002Fmain\u002Fbackend\u002Fskills\u002Fxurl\u002FSKILL.md",[],[],{"skillNo":74,"name":75,"nameZh":6,"description":76,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":77,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":18},"01M7CVK22A44A88NPPBAC1FVQP","xlsx","Create, read, edit Excel .xlsx workbooks and CSVs.","https:\u002F\u002Fgithub.com\u002Fdwikanugraha13\u002FProject-Anara\u002Fblob\u002Fmain\u002Fbackend\u002Fskills\u002Fxlsx\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fdwikanugraha13\u002FProject-Anara\u002Fblob\u002Fmain\u002Fbackend\u002Fskills\u002Fxlsx\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":84,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":18},"01M7CVJX88C8PY2T6RQZ5GCG15","weights-and-biases","W&B: log ML experiments, sweeps, model registry, dashboards.","https:\u002F\u002Fgithub.com\u002Fdwikanugraha13\u002FProject-Anara\u002Fblob\u002Fmain\u002Fbackend\u002Fskills\u002Fweights-and-biases\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":92,"categories":93,"keywords":94,"publishedAt":18},"01M7CVJR3W1FBRGC56DG6BJ1Y3","weekly-review-planning","Weekly reset: commitments, stalled work, next-week plan.","https:\u002F\u002Fgithub.com\u002Fdwikanugraha13\u002FProject-Anara\u002Fblob\u002Fmain\u002Fbackend\u002Fskills\u002Fweekly-review-planning\u002FSKILL.md",[],[],{"skillNo":96,"name":97,"nameZh":6,"description":98,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":99,"categories":100,"keywords":101,"publishedAt":18},"01M7CVJGPJNPQDM8S1KTTMJN7M","touchdesigner-mcp","Control TouchDesigner via twozero MCP.","https:\u002F\u002Fgithub.com\u002Fdwikanugraha13\u002FProject-Anara\u002Fblob\u002Fmain\u002Fbackend\u002Fskills\u002Ftouchdesigner-mcp\u002FSKILL.md",[],[]]