Command Dispatch
How bulker routes commands at runtime, from shimlink invocation to container execution or host binary handoff.
Dispatch flow
Section titled “Dispatch flow”When you type a shimlinked command (e.g., samtools view file.bam):
- argv[0] detection — The OS invokes the shimlink, which is a symlink to the
bulkerbinary. Bulker readsargv[0]and seessamtoolsinstead ofbulker. - BULKERCRATE lookup — Bulker reads the
BULKERCRATEenvironment variable to identify the active crate. - Manifest load — The cached manifest YAML is loaded from
~/.config/bulker/manifests/. - Command lookup — Bulker finds the matching
PackageCommandentry in the manifest. - Container command construction — Bulker builds the
docker runorapptainer execcommand with volumes, envvars, user mapping, and auto-mounted argument paths. - Spawn with signal forwarding — The container process is spawned as a child process. Bulker forwards signals (SIGINT, SIGTERM) to the container.
Containerized commands
Section titled “Containerized commands”Shimlinks point to the bulker binary. When invoked, bulker constructs the full container command:
- Docker:
docker run --rmwith-vvolume mounts,-eenvironment variables (all host vars by default, or only the allowlist with--strict-env),--usermapping, and--network host(if configured). - Apptainer:
apptainer execwith--bindmounts. With--strict-env, adds--cleanenvand passes allowlisted vars via--env.
File path arguments are auto-detected and their parent directories are mounted into the container automatically.
Host commands
Section titled “Host commands”Host commands are native binaries included in a crate via host_commands in the manifest.
- Strict mode: The shimlink directory contains symlinks pointing directly to the resolved host binary path (resolved via
whichat activation time). Because the real binary path is the symlink target, tools like Python’s venv detection work correctly. - Non-strict mode: No shimlink directory entry is created. The command is found directly on the preserved PATH, which is appended after the shimlink directory.
Interactive variants
Section titled “Interactive variants”Prefixing a command name with _ (e.g., _samtools) triggers interactive/shell mode:
- Docker: Uses
bashas the entrypoint (TTY flags are auto-detected). - Apptainer: Launches an interactive
shellsession.
Environment variables used during dispatch
Section titled “Environment variables used during dispatch”| Variable | Purpose |
|---|---|
BULKERCRATE | Identifies the active crate (e.g., databio/pepatac:1.0.13). Set at activation time. |
BULKERCFG | Path to the bulker config file. Used to load engine settings and templates. |
BULKER_PRINT_COMMAND | When set, prints the generated container command instead of executing it. |
BULKER_STRICT_ENV | When set to 1, containers use a clean environment. For Docker: only allowlisted vars get --env flags. For Apptainer: adds --cleanenv then passes allowlisted vars via --env NAME=VALUE. |
BULKER_EXTRA_ENVVARS | Comma-separated list of additional env var names added to the --strict-env allowlist. Only has effect with BULKER_STRICT_ENV=1. |
BULKER_EXTRA_DOCKER_ARGS | Additional raw arguments appended to docker run. |
TMPDIR | Controls where shimlink directories are created. Defaults to /tmp. Set to a writable path if /tmp is unavailable. |