Skip to content

Compose: Undocumented flag --interactive for docker compose exec #23352

@polarathene

Description

@polarathene

Is this a docs issue?

  • My issue is about the documentation content or website

Type of issue

Information is incorrect

Description

When responding to a contribution, I noticed that the docs for docker compose exec have no -i / --interactive flag (docker exec, docker run, docker compose run all do). This was pointed out back in mid 2023 with a response that it was intentional.

While it doesn't make sense to invoke --interactive with Docker Compose given it's an implicit default, similar to how --tty has been replaced with --no-TTY (this really should accept all lowercase btw), the interactive flag does remain supported for legacy reasons (as noted at earlier linked ref).


Actual valid use-case however has been shown here where I advised a contributor about this hidden flag so that they could ensure a command was run non-interactively within a running container.

Not being able to do this would prevent the bash read -p command from working properly in a non-interactive context.

# Defaults: `--tty=false` + `--interactive=false`
docker exec container-name some-command

# Defaults: `--no-TTY=false` + `--interactive=true`
docker compose exec --no-TTY --interactive=false service-name some-command

Where some-command would call read -p to provide an interactive prompt otherwise, where:

  • Only --no-TTY: Prompt is hidden but otherwise remains interactive.
  • Only --interactive=false: Prompt appears and hangs as no input can actually be received.
  • Both opt-out flags used: No prompt shown and no stdin to receive input, proper non-interactive shell.
  • Neither opt-out present: Prompt appears and responds to input interactively. Blocks automation without workarounds.

Location

https://docs.docker.com/reference/cli/docker/compose/exec/

Suggestion

Document -i / --interactive is actually supported with a default of true and that it is also enabled by compose by default (similar to the equivalent docs of the --no-TTY option).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions