diff options
| author | Pjotr <wrk@bosa.lan> | 2026-11-12 15:35:20 +0000 |
|---|---|---|
| committer | Pjotr <wrk@bosa.lan> | 2026-11-12 15:35:20 +0000 |
| commit | df684f4481dc4bc9c6331b11ede16b3d7d7a2ed8 (patch) | |
| tree | 888a5a81783a17b5232505ca17cc7a792e39009e | |
| parent | 4a494fe2e30a948a53214a3e1ebc1a1f06bbd3a9 (diff) | |
| download | run-guix-container-df684f4481dc4bc9c6331b11ede16b3d7d7a2ed8.tar.gz | |
README: a worked example for service containers, and a licence
The README explained the protocol, the fingerprint, the privileges and the privilege boundary well; what it did not have was the sequence for the case people actually hit -- a container whose services the host then talks to. New section "Worked example: a service container other programs talk to": --network shares the host's network namespace so container services are at 127.0.0.1:PORT on the host (and why that is not the daemon's --port); build the launcher with `guix system container -d` + `guix build` before letting the daemon start it, because `guix system container` builds *and* runs in the foreground; and the trap that bit during a real test -- a `--share` whose host path does not exist is dropped silently, so create it first. Plus the two timings worth having: a container is at its services ~2 s after START when the store paths are built, ~45 s on first boot while activation generates keys and lays out spool directories, so a client that gives up after a few seconds is measuring the wrong case. Boot output is where to look: LOG/--log, or /var/log/guix-containers/<pid>.log subject to the unit's LogsDirectory. LICENSE is now BSD 3-Clause (Copyright (c) 2026 Pjotr Prins), the same text as ai-memory's, and the README ends with a pointer to it.
| -rw-r--r-- | LICENSE | 29 | ||||
| -rw-r--r-- | README.md | 47 |
2 files changed, 76 insertions, 0 deletions
diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5a0e34a --- /dev/null +++ b/LICENSE @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2026, Pjotr Prins <wrk@bosa.lan> +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md index a771f15..562b0ed 100644 --- a/README.md +++ b/README.md @@ -287,6 +287,49 @@ Add a service to the OS configuration: (stop #~(make-kill-destructor))))) ``` +## Worked example: a service container other programs talk to + +The pattern that matters in practice is a container whose services the *host* +then uses over loopback. `--network` shares the host's network namespace, so a +service listening on a port inside the container is reachable at +`127.0.0.1:PORT` on the host -- no port forwarding and no NAT. (The daemon's +own `--port` is a different thing: it is the socket you send `START` to.) + +Build first, start second. `guix system container ...` builds *and* runs the +container in the foreground, which is not what you want when a daemon is going +to own it: + +```sh +# 1. get the launcher's derivation, then build the launcher +guix system container -d --network --share=/srv/share config.scm # -> /gnu/store/HASH-run-container.drv +guix build /gnu/store/HASH-run-container.drv # -> /gnu/store/HASH-run-container + +# 2. let the daemon start it (it validates the launcher, detaches it, and +# enforces one container at a time) +./run-guix-container.rb --daemon 127.0.0.1:8989 CONTAINER_HASH + +# 3. it is now running; talk to its services on the host +curl http://127.0.0.1:PORT/... +``` + +`--share=HOSTDIR` mounts a host directory inside the container at the same +path. A `--share` whose host path does **not** exist at container start is +dropped silently -- Guix does not warn -- so create the directory first, and if +a container cannot see a shared path, check it exists before looking at the +container. + +Two timings worth knowing when testing (measured on a Slurm cluster container, +2026-11-12): a container reaches its services in about **2 s** from `START` +when the store paths are already built, and about **45 s** on its first boot, +where activation still has to generate keys and lay out its spool and log +directories. If a test client gives up after a few seconds, it is measuring the +first case and losing against the second. + +Boot output is the way to see what a container is doing: `LOG HASH` over the +protocol, `--log HASH` from the client, or `/var/log/guix-containers/<pid>.log` +on the host (which the daemon warns it cannot write without +`LogsDirectory=`/`ReadWritePaths=`, see the unit files below). + ## Containers and VMs Container definitions live in `services/`, VM definitions in `vms/`. @@ -422,3 +465,7 @@ Other options researched: locally before talking to the daemon. * `test/` — unit tests for the container-launcher and daemon fingerprint logic (`test/run.sh`). + +## Licence + +BSD 3-Clause -- see [LICENSE](LICENSE). |
