fix: only pass ConsoleSize to ExecAttach when TTY is enabled#13616
Merged
ndeloof merged 1 commit intodocker:mainfrom Mar 4, 2026
Merged
fix: only pass ConsoleSize to ExecAttach when TTY is enabled#13616ndeloof merged 1 commit intodocker:mainfrom
ndeloof merged 1 commit intodocker:mainfrom
Conversation
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
ndeloof
approved these changes
Mar 4, 2026
glours
approved these changes
Mar 4, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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.