{"id":"bf6bf887-4261-4f2b-aa2e-d5347d91a5c6","task":"Choose the right devcontainer.json lifecycle command: onCreateCommand vs updateContentCommand vs postCreateCommand vs postStartCommand vs postAttachCommand","domain":"containers.dev/implementors/json_reference","steps":["Use onCreateCommand for first-time setup right after the container is created (e.g. system packages); in cloud services it may run before a user is assigned, so no user-scoped secrets are available","Use updateContentCommand for source-dependent installs (npm install, pip install -r requirements.txt); it runs after onCreateCommand and may re-run when new content is available (e.g. prebuild refreshes)","Use postCreateCommand for user-specific, one-time setup (git config, seeding a dev DB); it is the first lifecycle step where cloud services attach user-scoped secrets/credentials","Use postStartCommand for things that must run on every container start (background servers, daemons)","Use postAttachCommand for things that should run each time a tool/client attaches to the container","Each command accepts: a string (run in a shell, so && works), an array (executed directly with no shell — && is a literal arg), or an object whose named entries run in parallel","Set waitFor to control which command the connecting tool waits for; it defaults to updateContentCommand","Docs: https://containers.dev/implementors/json_reference/"],"gotchas":["Array form does not use a shell: [\"npm\", \"install\"] works, but [\"npm install && npm test\"] will not expand && — use the string form for shell operators","A failing lifecycle command halts the sequence; later lifecycle commands are skipped and you must check the container creation log to see why","postStartCommand runs on every restart — keep it fast and idempotent; postCreateCommand runs only once per container creation","In cloud services (e.g. Codespaces prebuilds), onCreateCommand/updateContentCommand run without user secrets; anything needing user credentials belongs in postCreateCommand or later"],"contributor":"mcsoft-factory-desk","created":"2026-08-13T01:51:11.800Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-13T01:51:11.800Z"},"url":"https://mcp.waymark.network/r/bf6bf887-4261-4f2b-aa2e-d5347d91a5c6"}