Skip to content

fix: only pass ConsoleSize to ExecAttach when TTY is enabled#13616

Merged
ndeloof merged 1 commit intodocker:mainfrom
mikesir87:fix-compose-hooks-tty-issue
Mar 4, 2026
Merged

fix: only pass ConsoleSize to ExecAttach when TTY is enabled#13616
ndeloof merged 1 commit intodocker:mainfrom
mikesir87:fix-compose-hooks-tty-issue

Conversation

@mikesir87
Copy link
Member

Resolves #13615

Disclaimer: this PR was generated with the assistance of Claude Code

What I did

Fixed a regression introduced in v5.1.0 where starting a Compose stack with post_start lifecycle hooks fails with:

console size is only supported when TTY is enabled

The new moby/moby client (v0.2.2) added client-side validation in ExecAttach: if ConsoleSize has non-zero dimensions, TTY must also be true.

Previously, ConsoleSize was populated unconditionally from GetTtySize() — which returns your real terminal dimensions when running Compose interactively. This caused the error for any service without tty: true (the default).

The fix is to only read and pass ConsoleSize when service.Tty is true, since console dimensions are meaningless without a TTY. A regression test is included that uses a real PTY (via containerd/console) to simulate interactive terminal conditions, ensuring GetTtySize() returns non-zero values and the bug would be caught if reintroduced.

The moby/moby client (v0.2.2) validates that ConsoleSize is zero when
TTY is disabled, returning "console size is only supported when TTY is
enabled" otherwise. Previously, ConsoleSize was populated unconditionally
from GetTtySize(), which returns real terminal dimensions when Compose is
run interactively — causing post_start hooks to fail for services without
`tty: true`.

Fix by only reading and passing the console size when service.Tty is true.

Signed-off-by: Michael Irwin <michael.irwin@docker.com>

Resolves docker#13615
@mikesir87 mikesir87 requested a review from a team as a code owner March 4, 2026 17:48
@mikesir87 mikesir87 requested review from glours and ndeloof March 4, 2026 17:48
@codecov
Copy link

codecov bot commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@ndeloof ndeloof merged commit 4915b77 into docker:main Mar 4, 2026
76 of 78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Compose lifecycle hooks causing errors

3 participants