Skip to content

[BUG] CLI compose up and down hangs with ttyWriter #13639

@richardkapolnai

Description

@richardkapolnai

Description

There is a race condition in the display rendering. When running commands docker compose up or docker compose down, the CLI sporadically hangs indefinitely at the very end of execution.

The Docker daemon remains healthy and all target containers successfully reach their expected states.

Workaround

Bypassing the interactive TTY via export COMPOSE_PROGRESS=plain completely prevents the hang.

Steps To Reproduce

Here are my "chaos monkey" scripts that spams SIGWINCH to force the UI to redraw rapidly while a 30-replica service starts up and tears down. Managed to reproduce on both Linux and Mac.

  1. Save the attached files compose.yml, winch.sh, reproduce.sh
  2. Run ./winch.sh in one terminal
  3. Run ./reproduce.sh in another terminal
  4. After a few iterations (wait 5-10 minutes), the CLI will freeze indefinetely. SIGQUIT to docker-compose will result the output trace.txt (attached below)

winch.sh
compose.yml
reproduce.sh

Compose Version

Docker Compose version v5.1.0
Docker version 29.2.1, build a5c7197
TERM=xterm-256color

Docker Environment

Client:
 Version:    29.2.1
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  agent: create or run AI agents (Docker Inc.)
    Version:  v1.29.0
    Path:     /Users/richardkapolnai/.docker/cli-plugins/docker-agent
  ai: Docker AI Agent - Ask Gordon (Docker Inc.)
    Version:  v1.19.0
    Path:     /Users/richardkapolnai/.docker/cli-plugins/docker-ai
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.32.1-desktop.1
    Path:     /Users/richardkapolnai/.docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  v5.1.0
    Path:     /Users/richardkapolnai/.docker/cli-plugins/docker-compose
  debug: Get a shell into any image or container (Docker Inc.)
    Version:  0.0.47
    Path:     /Users/richardkapolnai/.docker/cli-plugins/docker-debug
  desktop: Docker Desktop commands (Docker Inc.)
    Version:  v0.3.0
    Path:     /Users/richardkapolnai/.docker/cli-plugins/docker-desktop
  dhi: CLI for managing Docker Hardened Images (Docker Inc.)
    Version:  v0.0.0-alpha
    Path:     /Users/richardkapolnai/.docker/cli-plugins/docker-dhi
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.31
    Path:     /Users/richardkapolnai/.docker/cli-plugins/docker-extension
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v1.4.0
    Path:     /Users/richardkapolnai/.docker/cli-plugins/docker-init
  mcp: Docker MCP Plugin (Docker Inc.)
    Version:  v0.40.1
    Path:     /Users/richardkapolnai/.docker/cli-plugins/docker-mcp
  model: Docker Model Runner (Docker Inc.)
    Version:  v1.1.5
    Path:     /Users/richardkapolnai/.docker/cli-plugins/docker-model
  offload: Docker Offload (Docker Inc.)
    Version:  v0.5.70
    Path:     /Users/richardkapolnai/.docker/cli-plugins/docker-offload
  pass: Docker Pass Secrets Manager Plugin (beta) (Docker Inc.)
    Version:  v0.0.24
    Path:     /Users/richardkapolnai/.docker/cli-plugins/docker-pass
  sandbox: Docker Sandbox (Docker Inc.)
    Version:  v0.12.0
    Path:     /Users/richardkapolnai/.docker/cli-plugins/docker-sandbox
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     /Users/richardkapolnai/.docker/cli-plugins/docker-sbom
  scout: Docker Scout (Docker Inc.)
    Version:  v1.20.1
    Path:     /Users/richardkapolnai/.docker/cli-plugins/docker-scout

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 94
 Server Version: 29.2.1
 Storage Driver: overlayfs
  driver-type: io.containerd.snapshotter.v1
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 2
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 CDI spec directories:
  /etc/cdi
  /var/run/cdi
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: dea7da592f5d1d2b7755e3a161be07f43fad8f75
 runc version: v1.3.4-0-gd6d73eb8
 init version: de40ad0
 Security Options:
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.12.76-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: aarch64
 CPUs: 8
 Total Memory: 15.6GiB
 Name: docker-desktop
 ID: ac9f9919-4b9e-4964-bf43-7dbf1c6a2645
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Labels:
  com.docker.desktop.address=unix:///Users/richardkapolnai/Library/Containers/com.docker.docker/Data/docker-cli.sock
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  ::1/128
  127.0.0.0/8
 Live Restore Enabled: false

Anything else?

I have attached the full SIGQUIT trace showing the deadlock.

My AI friend suggests a lock inversion between two goroutines:

  1. The Main Thread is blocked in ttyWriter.Done() (tty.go:185) trying to close the UI.
  2. The UI Thread is blocked in ttyWriter.printWithDimensions() (tty.go:296) waiting to acquire the Mutex to redraw the terminal.
    This collision happens most frequently when the UI is bombarded with state changes (e.g., many replicas finishing healthchecks simultaneously) combined with terminal redraw events (SIGWINCH).

trace.txt

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions