You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -150,7 +151,7 @@ Environment variables available inside the container. Set by VS Code at containe
150
151
|----------|-------|---------|
151
152
|`DCT_HOME`|`/opt/devcontainer-toolbox`| Root of the toolbox installation. All scripts reference this. |
152
153
|`DCT_WORKSPACE`|`/workspace`| The mounted project directory. Scripts use this instead of hardcoding `/workspace`. |
153
-
|`DCT_IMAGE_VERSION`| e.g. `1.7.23`| The image version this devcontainer.json was last updated for. `dev-update` downloads the latest template which has this set by CI. VS Code detects the change and prompts rebuild. |
154
+
|`DCT_IMAGE_VERSION`| e.g. `1.7.31`| The image version this devcontainer.json was last updated for. `dev-update` downloads the latest template which has this set by CI. VS Code detects the change and prompts rebuild. |
154
155
155
156
#### Host detection variables
156
157
@@ -285,22 +286,42 @@ Adds a tiny init process (`tini`) as PID 1 inside the container. This properly h
Runs after VS Code connects to the container, on every start. At this point `remoteEnv` variables (`DEV_HOST_*`) are available.
295
+
Runs on the **host machine** before the container starts. This is the only devcontainer lifecycle command that executes outside the container.
296
+
297
+
Used to capture the host's real hostname, which is not available via `remoteEnv` on macOS (zsh doesn't export `HOSTNAME`). The file `.devcontainer.secrets/env-vars/.host-hostname` is read by `config-host-info.sh` as a fallback when `DEV_HOST_HOSTNAME` is empty.
295
298
296
-
This refreshes `.devcontainer.secrets/env-vars/.host-info` with correct host detection data (OS, username, Docker engine info). The ENTRYPOINT runs before VS Code injects remoteEnv, so it cannot detect the host — `postStartCommand` fills this gap.
299
+
| Platform | What `hostname -s` returns |
300
+
|----------|---------------------------|
301
+
| macOS | Machine name (e.g., `MBP-J4G0G066W2`) |
302
+
| Linux | Machine hostname (e.g., `terje-desktop`) |
303
+
| Windows (WSL2) | WSL hostname |
304
+
| Windows (PowerShell) | Falls back to `hostname` without `-s`|
297
305
298
-
**Why not in the entrypoint:** The entrypoint is a Docker-level construct that runs before VS Code connects. `remoteEnv` variables are injected by VS Code after the container starts. Any host detection in the entrypoint sees empty `DEV_HOST_*` variables and writes `unknown`.
306
+
The `mkdir -p` ensures the secrets directory exists on fresh installs. The file is in `.devcontainer.secrets/` which is gitignored.
Adds a tiny init process (`tini`) as PID 1 inside the container. This properly handles zombie processes and signal forwarding.
316
+
Runs after VS Code connects to the container, on every start. At this point `remoteEnv` variables (`DEV_HOST_*`) are available.
317
+
318
+
This refreshes `.devcontainer.secrets/env-vars/.host-info` with correct host detection data (OS, username, hostname, Docker engine info). The data is used by OTel telemetry, `dev-env`, and Grafana dashboards.
319
+
320
+
**Why not in the entrypoint:** The ENTRYPOINT is a Docker-level construct that runs before VS Code connects. `remoteEnv` variables are injected by VS Code after the container starts. Any host detection in the entrypoint sees empty `DEV_HOST_*` variables and writes `unknown`. `postStartCommand` runs after VS Code has set up the environment.
321
+
322
+
**Execution order on container start:**
323
+
1.`initializeCommand` — on host, captures hostname
324
+
2. ENTRYPOINT — in container, no remoteEnv (git identity, services, tool install)
325
+
3.`postStartCommand` — in container, remoteEnv available (host info detection)
305
326
306
327
**Must be `true`** — without it, orphaned child processes (from background tools, services, or crashed scripts) accumulate and never get reaped. The init process also ensures `SIGTERM` is forwarded correctly when the container stops, allowing graceful shutdown of services managed by supervisord.
0 commit comments