@kaynooo/cli-docker
v0.15.1
Published
dc: unified Docker Compose CLI — service picker/listing, health & error summary, redacted logs, shell/exec, deterministic ports, and compose passthrough.
Readme
docker
Unified Docker Compose CLI (dc): service picker and listing, health and error summary, redacted logs, masked container environment inspection, one-shot container stats, shell/exec, deterministic ports, and compose passthrough.
bun install -g @kaynooo/cli-dockerCommands
| Command | What it does |
| --- | --- |
| dc / dc --json | without a terminal (a script, a pipe, an agent) it lists the services with their state, ports and image, --json for the full record. On a terminal it picks one instead: enter opens its shell (or brings it up), ctrl-l follows its logs, ctrl-r restarts, ctrl-x stops, ctrl-b rebuilds; the ones acted on last come first |
| dc - | the last picker action again |
| dc health [service...] | one line per service with its state and health, then the last distinct error lines of its logs (-n per service, --since 1h), a repeated message once with ×N and secrets masked as ev redact does; --all adds the last lines of a quiet service, --level warn keeps warnings too, and --grep <regex> keeps matching lines. Exits 1 when a service is down, unhealthy or logged a line; --fail-on down\|unhealthy\|errors (repeatable, all three by default) picks what counts |
| dc logs [service...] | prints or follows compose service logs with secrets masked by default (--tail N, --since <dur>, --grep <regex>, --errors, --follow / --no-follow, --raw). Follows on a terminal unless --no-follow or --grep is set; prints once off a terminal |
| dc env <service> [--grep <pattern>] [--json] | reads the container's environment via docker inspect (works even in distroless containers without an env binary) with secret values always masked by key-name heuristics, token/URL patterns and known .env secrets; --grep filters keys by case-insensitive regex and --json prints {service, container, env: [{key, value, masked}]} |
| dc stats [service...] [--json] | one-shot resource usage table (SERVICE, CPU, MEM, MEM %, NET I/O, BLOCK I/O, PIDS) via docker stats --no-stream for running containers of the stack (optionally narrowed to named services); --json prints the parsed records |
| dc shell [service] | opens an interactive shell in the service (bash when available, else sh; starts it if stopped) |
| dc exec <service> <cmd...> | runs a command inside a compose service on the nearest stack |
| dc port <name> [--min <n>] [--max <n>] [--json] | deterministic 32-bit FNV-1a host port for a service name (1024-32767 by default), warning on stderr when something already listens on it |
| dc ports [--json] | lists published host -> container ports across all discovered compose services |
| dc <compose args> | passes any other docker compose verb (up, down, ps, restart, stop, build, config...) to the nearest compose file (or .env setting COMPOSE_FILE) up to the repository root |
| dc <project> <compose args> | the same on a stack that came up from other files (-f docker-compose.prod.yaml --env-file .env.prod), found through the labels compose put on its containers |
With several stacks that only have containers here and no name, dc opens an interactive picker when a terminal is attached, and otherwise lists the projects. When it picked the stack through its containers it prints the compose command it stands for on stderr.
Services are named php for this folder's stack, api/php for a child folder's and <project>:php for a stack found through its containers; a bare name also finds the same service in a child folder.
Config
~/.config/kaynooo-cli/dc.json ($XDG_CONFIG_HOME/kaynooo-cli/ when set, falling back to dlog.json) takes tail (500 by default, the log lines read per service) and width (220, the longest error line kept) as positive whole numbers.
