-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Description
Companion issue to docker/compose#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: docker/compose#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.