Description
When running wrangler deploy on Windows with [[containers]] configured, the Docker build step spawns numerous console windows that flash open during the build process.
Root Cause
In wrangler-dist/cli.js, both dockerBuild() and runDockerCmd() use childProcess.spawn() with detached: true:
const child = childProcess.spawn(dockerPath, options.buildCmd, {
stdio: ["pipe", "inherit", "inherit"],
detached: true
});
From the Node.js docs:
On Windows, setting options.detached to true makes it possible for the child process to continue running after the parent exits. The child will have its own console window.
This causes Docker BuildKit's subprocesses to each open their own visible console window.
Suggested Fix
Set detached conditionally based on platform, and add windowsHide: true:
const child = childProcess.spawn(dockerPath, options.buildCmd, {
stdio: ["pipe", "inherit", "inherit"],
detached: process.platform !== "win32",
windowsHide: true
});
This preserves the existing behavior on macOS/Linux (detached for process group cleanup) while preventing console window spam on Windows. windowsHide: true is a no-op on non-Windows platforms.
Both dockerBuild() and runDockerCmd() in cli.js need this change.
Environment
- OS: Windows 11
- Wrangler: 4.72.0
- Node: 22
- Docker Desktop with BuildKit
Reproduction
- Create a Workers project with
[[containers]] in wrangler.toml pointing to a Dockerfile
- Run
wrangler deploy on Windows
- Observe many console windows spawning during the Docker build step
Description
When running
wrangler deployon Windows with[[containers]]configured, the Docker build step spawns numerous console windows that flash open during the build process.Root Cause
In
wrangler-dist/cli.js, bothdockerBuild()andrunDockerCmd()usechildProcess.spawn()withdetached: true:From the Node.js docs:
This causes Docker BuildKit's subprocesses to each open their own visible console window.
Suggested Fix
Set
detachedconditionally based on platform, and addwindowsHide: true:This preserves the existing behavior on macOS/Linux (detached for process group cleanup) while preventing console window spam on Windows.
windowsHide: trueis a no-op on non-Windows platforms.Both
dockerBuild()andrunDockerCmd()incli.jsneed this change.Environment
Reproduction
[[containers]]inwrangler.tomlpointing to a Dockerfilewrangler deployon Windows