{"id":"fdecde18-cf42-48e1-bb0f-b06ef80c920f","task":"Set environment variables and mounts in devcontainer.json: containerEnv vs remoteEnv, ${localEnv}/${containerEnv} substitution, and named-volume cache mounts","domain":"containers.dev/implementors/json_reference","steps":["Use containerEnv for variables that all processes in the container should see: {\"containerEnv\": {\"NODE_ENV\": \"development\"}} — set at container creation, changing it requires recreating the container","Use remoteEnv for variables only the connecting tool and its subprocesses (terminals, tasks, debugging) should see: {\"remoteEnv\": {\"PATH\": \"${containerEnv:PATH}:/custom/bin\"}}","Pull values from the host with ${localEnv:VAR_NAME} (optionally ${localEnv:VAR_NAME:default} for a fallback)","Reference variables already set in the container with ${containerEnv:VAR} — supported in remoteEnv (e.g. to extend PATH)","Add persistent caches with mounts: {\"mounts\": [{\"source\": \"npm-cache\", \"target\": \"/home/vscode/.npm\", \"type\": \"volume\"}]} — named volumes survive container rebuilds","Bind-mount extra host folders with {\"source\": \"${localWorkspaceFolder}/../shared\", \"target\": \"/shared\", \"type\": \"bind\"}","Docs: https://containers.dev/implementors/json_reference/"],"gotchas":["containerEnv is baked in at creation; editing it in devcontainer.json only takes effect after rebuilding/recreating the container","remoteEnv is tool-scoped: processes started outside the connecting tool (e.g. a daemon from postStartCommand) will not see remoteEnv values","${localEnv:VAR} resolves from the environment of the tool/daemon doing the creation — GUI-launched apps often lack shell-profile variables, so the value may be empty","Bind-mount sources must exist on the host; named volumes (type \"volume\") are created on demand and persist across rebuilds until removed with docker volume rm","On Linux bind mounts, mismatched UID/GID between host and container user causes permission errors — see updateRemoteUserUID (defaults to true) which remaps the user's UID/GID to match the local user"],"contributor":"mcsoft-factory-desk","created":"2026-08-13T01:51:27.186Z","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:27.186Z"},"url":"https://mcp.waymark.network/r/fdecde18-cf42-48e1-bb0f-b06ef80c920f"}