Skip to content

Conversation

@tonyo
Copy link
Contributor

@tonyo tonyo commented Oct 23, 2025

What I did

Replaced backticks with single quotes in the help output of docker compose exec for the --no-TTY option.

Currently the output of docker compose exec --help looks like this:

✘ $ docker compose exec --help
Usage:  docker compose exec [OPTIONS] SERVICE COMMAND [ARGS...]

Execute a command in a running container

Options:
  -d, --detach                       Detached mode: Run command in the background
      --dry-run                      Execute command in dry run mode
  -e, --env stringArray              Set environment variables
      --index int                    Index of the container if service has multiple replicas
  -T, --no-TTY docker compose exec   Disable pseudo-TTY allocation. By default docker compose exec allocates a TTY.
      --privileged                   Give extended privileges to the process
  -u, --user string                  Run the command as this user
  -w, --workdir string               Path to workdir directory for this command

Note the -T line:

  -T, --no-TTY docker compose exec   Disable pseudo-TTY allocation. By default docker compose exec allocates a TTY.

That "docker compose exec" part after --no-TTY is most likely unintentional; it's there because Cobra (or more specifically, pflag) found the backticks and extracted the wrapped value via UnquoteUsage function.
This is a not-so-well documented behavior, see e.g. this and this.

After the change the output looks as expected:

✓ $ ./bin/build/docker-compose exec --help
Usage:  docker compose exec [OPTIONS] SERVICE COMMAND [ARGS...]

Execute a command in a running container

Options:
  -d, --detach            Detached mode: Run command in the background
      --dry-run           Execute command in dry run mode
  -e, --env stringArray   Set environment variables
      --index int         Index of the container if service has multiple replicas
  -T, --no-tty            Disable pseudo-TTY allocation. By default 'docker compose exec' allocates a TTY.
      --privileged        Give extended privileges to the process
  -u, --user string       Run the command as this user
  -w, --workdir string    Path to workdir directory for this command

Note

The By default 'docker compose exec' allocates a TTY. part of the output is not entirely correct, given that the default value of the flag is !dockerCli.Out().IsTerminal() (source). It'd be more like, "By default 'docker compose exec' allocates a TTY when the output is a terminal."
Let me know if that sounds better and I'll update it in a separate PR.

(not mandatory) A picture of a cute animal, if possible in relation to what you did

image

@tonyo tonyo requested a review from a team as a code owner October 23, 2025 15:28
@tonyo tonyo requested review from glours and ndeloof October 23, 2025 15:28
@ndeloof
Copy link
Contributor

ndeloof commented Oct 23, 2025

For legal reasons, contributor MUST sign-off commits before we can merge. Please amend your commit with git commit --signoff --amend and force push

@tonyo tonyo force-pushed the tonyo/fix-backticks-exec branch from f0169d2 to 14835bc Compare October 23, 2025 15:34
@ndeloof ndeloof enabled auto-merge (rebase) October 23, 2025 15:34
@ndeloof
Copy link
Contributor

ndeloof commented Oct 23, 2025

Nice catch by the way, this surprising feature in pflags we probably could use to improve help messages in a few places

Copy link
Contributor

@glours glours left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@glours
Copy link
Contributor

glours commented Oct 23, 2025

@tonyo You need to run make docs to update the documentation files

auto-merge was automatically disabled October 23, 2025 15:43

Head branch was pushed to by a user without write access

@tonyo tonyo force-pushed the tonyo/fix-backticks-exec branch from 14835bc to 57ad5f2 Compare October 23, 2025 15:43
@tonyo
Copy link
Contributor Author

tonyo commented Oct 23, 2025

You need to run make docs to update the documentation files

Done 👍

@ndeloof ndeloof enabled auto-merge (rebase) October 23, 2025 16:08
@ndeloof ndeloof merged commit 8619f5d into docker:main Oct 23, 2025
25 checks passed
@codecov
Copy link

codecov bot commented Oct 23, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

3 participants