Skip to content

[BUG] Error when stdin is not a TTY but stdout is a TTY #13228

Description

@SmartHypercube

Description

docker-compose will error with a misleading message when stdin is not a TTY but stdout is a TTY, and stdin_open: true. docker doesn't have this problem.

Steps To Reproduce

  1. compose.yaml:
services:
  main:
    image: debian:trixie
    command: ['cat']
    stdin_open: true
  1. echo a | docker-compose run --rm main | cat
    You will get an a as output.
  2. echo a | docker-compose run --rm main
    I expect to get an a as output, because echo a | docker run -i --rm debian:trixie cat also outputs an a. But I got the input device is not a TTY, which is misleading --- I did not ask for a TTY, why is docker-compose complaining the input device not being a TTY? And it's very hard to guess that the actual problem is related to stdout (being a TTY), not stdin.

Compose Version

# docker compose version
Docker Compose version 2.26.1-4
# docker-compose version
Docker Compose version 2.26.1-4

Docker Environment

Client:
 Version:    26.1.5+dfsg1
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  0.13.1+ds1
    Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: Docker Compose (Docker Inc.)
    Version:  2.26.1-4
    Path:     /usr/libexec/docker/cli-plugins/docker-compose
...
 Kernel Version: 6.12.43+deb13-amd64
 Operating System: Debian GNU/Linux 13 (trixie)
...

Anything else?

No response

Activity

  1. self-assigned this
    on Sep 17, 2025
  2. ndeloof commented on Sep 17, 2025

    @ndeloof
    Contributor

    the issue is not about allocating a TTY, but about running interactive. While docker run requires an explicit --interactive flag, docker compose run doesn't: interactive mode is the default mode for legacy reasons. Basically, most users of the docker run command always also pass -it flags, so compose made this the default behavior)

    You can disable this using docker compose run --interactive=false ...

  3. ndeloof commented on Sep 17, 2025

    @ndeloof
    Contributor

    Compose could detect user didn't explicitly set the --interactive flag, and if stdin isn't a TTY, should run non-interactive.
    wdyt @glours

  4. SmartHypercube commented on Sep 17, 2025

    @SmartHypercube
    Author

    I understand this behavior now and I can see that it is for legacy reasons. However, I do think docker compose should not error in this reasonable use case, or at least, should print a better message, let the user has some clue about how to fix the problem.

  5. glours commented on Sep 17, 2025

    @glours
    Contributor

    @SmartHypercube The error message isn’t coming from Compose itself, but from the engine, triggered by passing default attributes that lead to this behavior. As @ndeloof mentioned, there’s probably something we can do. I’ll take some time to propose a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions