Skip to content

Windows: Docker container builds spawn many console windows #12963

@GregACode

Description

@GregACode

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

  1. Create a Workers project with [[containers]] in wrangler.toml pointing to a Dockerfile
  2. Run wrangler deploy on Windows
  3. Observe many console windows spawning during the Docker build step

Metadata

Metadata

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions