Devcontainer Configuration
This page is the flat reference for every field, env var, and CLI flag that governs Crewship’s devcontainer runtime. For the step-by-step narrative, see Guides → Devcontainers & Runtime Images.Per-crew fields
Stored on thecrews table, settable via UI wizard, REST PATCH, or crewship crew config.
devcontainer_config schema
Parser: internal/devcontainer/config.go:Config.
Allowed feature registries
Feature IDs are validated against an allowlist ininternal/devcontainer/features.go to avoid arbitrary OCI artifact execution. Accepted prefixes:
ghcr.io/devcontainers/features/*— officialghcr.io/devcontainers-extra/features/*— extras (claude-code, opencode, codex, …)ghcr.io/devcontainers-community/features/*ghcr.io/crewship-ai/features/*— reserved for first-party features
devcontainer-feature.json installsAfter (either spec form ["common-utils"] or legacy wild form [{"id":"common-utils"}]) are honoured by the topological sort in SortFeatures.
Canonical feature set for every Crewship crew
These two are considered the minimum to turn a bare Debian/Ubuntu image into a working Crewship crew container:common-utilscreates theagentuser at UID 1001 and installscurl,git,ca-certificates,sudo. Crew create and crew update inject it when it is missing.claude-codeinstalls Node.js 22 (NodeSource) +@anthropic-ai/claude-codeglobally. Replaces the deletedEnsureClaudeCodeGo helper.
The runtime account: agent, UID 1001
Every crew container runs as UID 1001, so the image needs an account agent
with UID and GID 1001. Without it, anything that looks up the current user fails:
sudo: you do not exist in the passwd database, whoami: cannot find name for user ID 1001, and git or ssh refusing to run.
- No
common-utilsin the config: crew create and crew update add it withusername: agent,userUid: 1001,userGid: 1001. This coverscrewship crew config <crew> --devcontainer <file>,PATCH /crews/{id}and everycrewship apply. common-utilsdeclared without account options, or withautomatic: they are set toagent/1001/1001. Other options you set are kept.- Only the
featuresblock changes. The rest of the config is stored as you wrote it, so reading it back shows your keys plus the account. - A different
username,userUidoruserGid: create, update and provisioning refuse the config withcommon-utils must create user 'agent' with UID/GID 1001and name the option to change. username: noneorroot: common-utils creates no account, and the options are left alone. The base image must then provideagentat UID/GID 1001 itself.
crewship apply compares a manifest’s devcontainer with the stored config in
the same settled form. Re-applying the manifest that created a crew therefore
plans = for it, not an update. Some existing crews plan one update that
settles their stored config and then rebuild once at the next provision: a
crew whose stored config lost the account (an update before this fix stored a
bare config as is), one whose stored config still carries the old uid /
gid names, and one whose config an earlier create re-marshalled without keys
Crewship does not model (such as hostRequirements).
Because update now adds common-utils too, a crew on a prebuilt image that
already has agent at 1001 and declares no features gets a feature build
after its next config change, as it would at create. That build needs
registry access and a package manager in the image. To skip it, declare
common-utils with username: none.
If the base image already has a different user or group at UID or GID 1001,
the explicit 1001 can make the account step fail at build time. Use a base
image without one; such an image never had a working runtime account anyway.
The option names are userUid and userGid. Crewship versions before this
change injected uid and gid, which common-utils does not read. The account
then got an automatic UID: 1001 only when the base image already had a user at
1000 (the node or vscode images), and 1000 on debian:bookworm-slim. Such a
stored config is built with the correct names the next time it is provisioned
(after a config change, or with crewship crew provision <crew> or
crewship crew rebuild <crew>); the stored config itself is not rewritten, so
reading it back still shows uid / gid. That changes its cache key, so it
builds a new image once; crews with the same config share that build. This
includes crews on the default configuration, whose stored definition also
carries the old names; their image already had agent at 1001, so the rebuild
changes nothing for them. Upgrading alone rebuilds nothing: restarting the
server or the crew (crewship crew stop / start) keeps the current image, so
a crew built on a slim image stays broken until it is provisioned again. To fix
it, run crewship crew rebuild <crew>.
sudo works while the image is built (in postCreateCommand), once the account
exists. On the Docker runtime it does not work inside a running crew container:
containers run with no-new-privileges and a read-only root filesystem (unless
the crew is privileged), so install system packages at build time, preferably
as features, not from an agent.
mise_config schema
mise as the agent user, then mise install per tool. Versions follow mise semantics (latest, 22, 22.11.0, lts).
Environment variables
Extend the main environment reference. These govern the bind-mount pipeline.Autodetect order
internal/config/config.go:autodetectSidecarPaths walks these candidates and picks the first hit:
Sidecar binary
{dir of executable}/crewship-sidecar— tar.gz / installer layout{dir of executable}/../libexec/crewship-sidecar— Homebrew layout{dir of executable}/../libexec/crewship/crewship-sidecar— deb/rpm FHS layout (/usr/libexec/crewship/)/usr/local/bin/crewship-sidecar
{dir of executable}/entrypoint.sh— tar.gz / installer layout{dir of executable}/../libexec/entrypoint.sh— Homebrew layout{dir of executable}/../libexec/crewship/entrypoint.sh— deb/rpm FHS layout (/usr/libexec/crewship/){cwd}/scripts/entrypoint.sh{cwd}/entrypoint.sh/usr/local/share/crewship/entrypoint.sh
crewship on your PATH resolves to its real Cellar directory (where the libexec sibling lives).
If either remains empty and CREWSHIP_SKIP_SIDECAR != 1, config.Load returns a descriptive error and the server refuses to start.
REST endpoints
REST contract
All routes in this section require an authenticated request. Crew routes also require workspace context and resolvecrewId within that workspace.
GET /api/v1/crews//provision
Auth: Authenticated workspace request. Request:crewId path parameter; no body. Response: 200 OK with the current status, cached image tag, and config hash. Statuses: 200 OK or 404 Not Found when the crew is not in the caller’s workspace.
POST /api/v1/crews//provision
Auth: Authenticated workspace caller with the provisioning write permission. Request:crewId path parameter; no body. Response: 202 Accepted when the asynchronous job is queued. Statuses: 202 Accepted, or 400, 403, 404, 409, 429, 500, or 503 for the validation, permission, workspace, duplicate-job, rate-limit, server, or Docker-configuration conditions described in the provisioning reference.
POST /api/v1/crews//rebuild
Auth: Authenticated workspace caller with the provisioning write permission. Request:crewId path parameter; no body. Response: 202 Accepted when the rebuild job is queued; the previously selected image stays in place until the new build succeeds — the cache marker is not cleared up front. Statuses: 202 Accepted, or 403, 404, 409, 429, 500, or 503 for the corresponding conditions.
GET /api/v1/features/catalog
Auth: Authenticated request. Request: optionalsearch query parameter; no body. Response: 200 OK with a features array. Statuses: 200 OK; the handler uses its catalog fallback when the dynamic fetch fails.
GET /api/v1/runtimes/catalog
Auth: Authenticated request. Request: optionalsearch query parameter; no body. Response: 200 OK with a runtimes array. Statuses: 200 OK; the handler uses its catalog fallback when the dynamic fetch fails.
All endpoints require a workspace-authenticated user. ProvisionTrigger returns 503 Service Unavailable if the Docker client is not configured on the server.
CLI flags
Provisioning states
Emitted byProvisionStatus + WebSocket channel provision:{crewId}:
Validation rules
Enforced ininternal/api/crews.go write paths and devcontainer.Config.Validate:
image/runtime_image: non-empty, no whitespace/control chars, ≤ 512 chars.features: keys match the allowlisted registries above.postCreateCommand: ≤ 4096 chars per entry, no null bytes.containerEnv: ≤ 32 keys, each key[A-Z_][A-Z0-9_]*.mise_config: well-formed JSON,toolsmap only, ≤ 32 entries.- Total
devcontainer_configblob ≤ 100 KB. - Total
mise_configblob ≤ 10 KB.
Cache image naming
Successful provisions commit a reusable layer taggedcrewship-cache:{hash[:12]}, where hash is the SHA-256 of (runtime_image, devcontainer_config, mise_config). The full 64-char hash is written to crews.config_hash; the truncated 12-char form is used as the image tag so docker images stays legible.
- Cache hit — provisioner sees the
crewship-cache:{hash[:12]}image already exists and the crew row is in sync. No work is done;cached_imageis kept. - Cache miss — hash differs from
crews.config_hash, or the tagged image was pruned. Full feature + mise install runs and the new image is committed under the new hash.
containerEnv key or tweaking postCreateCommand changes the hash and creates a fresh cache image; the old one becomes eligible for GC after its last crew migrates off.
Runtime base-image digest check
internal/dockerutil/imagedigest.go keeps a HEAD-manifest cache of remote base-image digests (DefaultDigestTTL = 24 * time.Hour). On a provision request, the resolver checks whether the caller’s runtime_image reference still resolves to the digest baked into the existing cache image. If the registry has moved the tag (security update, rolled release), the provisioner treats the cache as stale even when the config_hash is unchanged and rebuilds.
- TTL: 24 hours. Empty/negative results are also cached so a missing upstream does not trigger a HEAD storm.
- Bypass: pin
runtime_imageto an explicit digest (ghcr.io/…@sha256:…). Digest-pinned references skip the HEAD round-trip. - Shared: the same resolver backs
GET /api/v1/cache/imagesso the admin UI and the provisioner do not double-pay for the registry check.
Background GC
ProvisioningHandler runs a sweeper every 30 minutes (and once at startup)
to remove crash leaks:
-
Temp containers — those named
crewship-provision-*and labelledcrewship.temp=provision— are force-removed once older than 1 hour. Both conditions are required, and the name is the one that authorises deletion. Crew containers now setcrewship.tempto the empty string at create, which stops the inheritance: the daemon merges an image label only for a key the create request leaves unset, so the explicit empty value wins and the container drops out of--filter label=crewship.temp=provision. Consequence fordocker ps: an exact-value filter (label=crewship.temp=provision) now lists only scratch containers plus any crew container created before this release. A key-only filter (label=crewship.temp) still lists every crew, because the key is present with an empty value. Filter byname=crewship-provision-when you want only genuine scratch containers — that is what the sweeper itself decides on. Scratch containers leaked before this release carry a Docker-assigned random name and are no longer swept automatically. Remove them by hand if they bother you —docker ps -a --filter label=crewship.temp=provision, then discount anything named like a crew. -
Cache images (
crewship-cache:*) with no referencing crew row across any workspace are flagged. A 5-minute age floor protects images that Provision() has just committed but not yet linked to a crew, eliminating the obvious race window. -
Intermediate feature images (
crewship-feat:*) — the per-feature layers the BuildKit path produces — are regenerable and never referenced by a crew row, so the sweeper treats any unreferenced one beyond the age floor the same way it treats orphaned cache images.
Image ownership
An installation with a settled identity builds its images inside its own namespace and labels them with their origin:{namespace} is the full installation identity (the
value of the crewship.instance-id container label). config_hash itself is
unchanged and not installation-specific.
- Crews of one installation still share an image when their configuration matches. New build cache lookups use distinct tags for each installation. This does not change existing selections or enforce deletion ownership. Base images and BuildKit layers remain shared by the daemon.
- A shared image names no crew. The labels record which installation built it; they are evidence of origin, not a permission to delete. What an installation still needs is decided by its database.
- The label keys are image-specific. A container inherits its image’s labels, and these keys are never used to recognise a runtime container.
- Without a settled identity (an in-memory database, or a second server on
the same database file) the legacy names
crewship-cache:{hash[:12]}andcrewship-feat:{hash[:12]}are used and reserved ownership labels are cleared to prevent inheritance. - Upgrading does not rebuild crews. A crew keeps running from the image it already selected, by immutable image ID; the namespace applies from the next build the crew needs. Images built before the upgrade are not claimed: they keep their legacy names, carry no labels, and stay under the opt-in policy below.
Storage check before a build
A build that fills the disk does not only fail: the database on the same volume starts failing writes. Before a build pulls the base image or builds a layer, the server checks free space and refuses the build if there is too little. (On Apple Containers the feature archives are downloaded first.) Reusing an existing image (a cache hit) is never refused, and nothing is deleted to make room.
The server can measure Docker’s storage when it reaches the daemon over a
local Unix socket, the daemon is not Docker Desktop, and Docker’s root
directory is visible to the server process. Docker Desktop, a remote daemon,
a VM-backed runtime and a server running in a container without that
directory mounted are not measured: the result is unknown and the build
proceeds. A probe that fails is treated the same way.
A refused build fails with
provision.failed (detail storage_preflight) and
a message naming the volume, its free space and the floor, for example
3.0 GiB free on Docker's storage (/var/lib/docker), a build needs at least 4.0 GiB. Free up space and build again.
Orphan deletion policy
Owned crew and feature image collection is experimental and off by default. SetCREWSHIP_IMAGE_GC=true only on a Docker daemon dedicated to one Crewship installation. Current selections, the previous immutable
selection of each live crew and all container source images are protected.
An owned image older than 24 hours may be removed, including an untagged
abandoned build, once it has stayed unused and unprotected for 24 hours as
observed by this installation at its 30-minute passes; a use seen at a pass
restarts that window, and so does a gap of more than two hours without a
completed pass. A
deleted crew’s selections stay protected for 7 days after the deletion. CREWSHIP_IMAGE_GC=false explicitly disables this policy.
Inventory runs outside the lifecycle gate. Final deletion checks exclude only
the candidate’s acquisitions through publication and restore replay, with a
two-second Docker operation budget. Missing ownership or incomplete inventory prevents deletion. Absent references
and malformed crew configurations are logged without freezing all collection.
The collector never recursively prunes parents or shared BuildKit cache.
CREWSHIP_CACHE_GC_AUTODELETE=true remains the separate explicit opt-in for
unlabelled historical artifacts, with its five-minute floor. Keep this legacy
switch off on shared daemons. CREWSHIP_CACHE_EVICTION is a deprecated explicit opt-in alias for owned
collection and no longer starts a second image sweeper. Copied/restored foreign
selections remain compatible, so default enablement still needs a reviewed
adoption/retention policy. See the full lifecycle contract.
Image-list cache
Docker’sImageList is O(n) over every image on the host. The cache inventory endpoint uses a 10-second image-list cache; deletion decisions use fresh inventory. GET /api/v1/cache/images caches its list so admin UI polling does not pay that cost on every request. The cache is invalidated on any commit/delete performed by the provisioner itself, so the caller always sees its own writes.