|
| 1 | +# nsenter Development Guide |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +Minimal Docker image (~600KB) providing a static `nsenter` binary for entering Linux namespaces from containers. Used for debugging containers and Kubernetes nodes. |
| 6 | + |
| 7 | +## Build & Test |
| 8 | + |
| 9 | +```bash |
| 10 | +# Build Docker image (replace VERSION with util-linux version, e.g. 2.41.3) |
| 11 | +docker build --build-arg UTIL_LINUX_VER=2.41.3 -t nsenter:local . |
| 12 | + |
| 13 | +# Test locally |
| 14 | +docker run -it --rm --privileged --pid=host nsenter:local |
| 15 | + |
| 16 | +# Multi-arch build |
| 17 | +docker buildx build --platform linux/amd64,linux/arm64 --build-arg UTIL_LINUX_VER=2.41.3 -t nsenter:local . |
| 18 | + |
| 19 | +# Run integration tests |
| 20 | +TEST_IMAGE=nsenter:local ./tests/test-docker.sh |
| 21 | +``` |
| 22 | + |
| 23 | +## Structure |
| 24 | + |
| 25 | +This is a minimal project: |
| 26 | +- `Dockerfile` — Multi-stage: builds static nsenter from util-linux sources (Debian builder) → copies to scratch base |
| 27 | +- `nsenter-node.sh` — Helper script for entering Kubernetes node namespaces via a privileged pod |
| 28 | +- `tests/test-docker.sh` — Integration tests (image size, binary version, scratch-based) |
| 29 | +- `.github/workflows/ci.yaml` — CI: lint (Hadolint + ShellCheck) + build + test on every push/PR |
| 30 | +- `.github/workflows/build-release.yaml` — Release: triggered on tag push, builds multi-arch (amd64 + arm64 native runners), pushes to GHCR, creates GitHub Release |
| 31 | + |
| 32 | +## Key Details |
| 33 | + |
| 34 | +- **Base image:** scratch (zero attack surface) |
| 35 | +- **Build source:** util-linux from GitHub releases (version pinned via `UTIL_LINUX_VER` build arg) |
| 36 | +- **Binary:** static nsenter (no shared libs), stripped |
| 37 | +- **Required privileges:** `--privileged` and `--pid=host` (or specific namespace flags) |
| 38 | +- **Use cases:** Enter host PID/network/mount namespaces from container, debug Kubernetes nodes |
| 39 | +- **Published to:** GHCR as `ghcr.io/alexei-led/nsenter` (Docker Hub deprecated) |
| 40 | +- **Default branch:** `master` |
| 41 | +- **Versioning:** Follows util-linux release tags (e.g., tag `2.42` → builds util-linux v2.42) |
| 42 | + |
| 43 | +## CI/CD Flow |
| 44 | + |
| 45 | +``` |
| 46 | +Push/PR → ci.yaml (lint + build + test) |
| 47 | +Git tag → build-release.yaml (multi-arch build → GHCR push → GitHub Release) |
| 48 | +``` |
| 49 | + |
| 50 | +## Important Notes |
| 51 | + |
| 52 | +- NEVER add AI co-author to git commits |
| 53 | +- Do not push directly to master — use PRs for non-trivial changes |
| 54 | +- Image must stay under 1MB (currently ~600KB) |
| 55 | +- Always test with `tests/test-docker.sh` before releasing |
0 commit comments