The defaults for -t / --tty (allocate a pseudo-TTY) and -i / --interactive (Keep STDIN open even if not attached) for docker compose exec and docker compose run are exactly the reverse as the corresponding docker (container) run / docker container exec commands.
For docker compose, users can disable these options using the -T / --no-TTY options; we'll unlikely be able to change these defaults on either side (also see #9202), but we could make the UX slightly more compatible by adding the same flags to docker compose subcommands.
Currently, trying to use the -i and/or -t options will produce an error;
docker compose run -it myservice
unknown shorthand flag: 'i' in -it
docker compose exec -it myservice
unknown shorthand flag: 'i' in -it
I propose to add these flags to (at least) the run and exec subcommands. Setting those options won't have an effect (as they're already set by default), but it allows users to use the same options when using compose (which can be just due to "muscle memory");
- Add
-t / --tty flag, with a default of true
- Add
-i / --interactive flag with a default of true
- Produce an error passing both
-t or -i and -T (conflicting options)
I should note that there's other commands on the docker / docker container that also accept -t and/or -i, such as docker (container) create, and a --no-stdin on docker (container) attach (but compose does not yet have an equivalent to that).
The defaults for
-t/--tty(allocate a pseudo-TTY) and-i/--interactive(Keep STDIN open even if not attached) fordocker compose execanddocker compose runare exactly the reverse as the correspondingdocker (container) run/docker container execcommands.For
docker compose, users can disable these options using the-T/--no-TTYoptions; we'll unlikely be able to change these defaults on either side (also see #9202), but we could make the UX slightly more compatible by adding the same flags todocker composesubcommands.Currently, trying to use the
-iand/or-toptions will produce an error;I propose to add these flags to (at least) the
runandexecsubcommands. Setting those options won't have an effect (as they're already set by default), but it allows users to use the same options when using compose (which can be just due to "muscle memory");-t/--ttyflag, with a default oftrue-i/--interactiveflag with a default oftrue-tor-iand-T(conflicting options)I should note that there's other commands on the
docker/docker containerthat also accept-tand/or-i, such asdocker (container) create, and a--no-stdinondocker (container) attach(but compose does not yet have an equivalent to that).