Skip to content

[Feature Request] exec/run switch to enable guessing when to allocate a TTY #3997

@jedwards1211

Description

@jedwards1211

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions