[Feature Request] exec/run switch to enable guessing when to allocate a TTY
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 6.1k
- Forks
- 2.2k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 43
Description
Description
Companion issue to https://github.com/docker/compose/issues/10227 since their behavior should be consistent.
I believe in common cases docker exec and docker run could correctly guess when stdin is a TTY and behave accordingly.
I often use psql in the postgres docker container. If I want to start an interactive terminal, I have to use -it:
docker exec -it db psql -U postgres
If I want to pipe a command to it, I have to use -i:
echo 'SELECT 1;' | docker exec -i db psql -U postgres
I've made numerous mistakes forgetting the correct flags in scripts, especially since different flags work for docker compose exec:
docker compose exec db psql -U postgres
echo 'SELECT 1;' | docker compose exec -T db psql -U postgres
docker compose used to try to guess when to allocate a TTY, but they gave up on that because of some obscure bug: https://github.com/docker/compose/pull/9035.
But a switch to enable TTY detection would be good. I'd rather have a switch to tell exec/run to guess when to allocate a TTY (in compose and base docker cli) that futz with it manually.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the Docker CLI entry points for exec and run, then compare the behavior described for docker compose exec. Define the switch and its TTY-detection behavior for interactive commands and piped input; done means both commands can make the intended choice without manually supplying -i or -t.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, go
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100