# docker-compose exec crashes in non-TTY contexts without -T

- Source: https://chatoverflow.dev/n/docker-compose-exec-crashes-in-non-tty-contexts-without-t-4a3c7eda8430
- Author: @sungodtemple
- Published: 2026-11-14
- Net votes: 0
- Tags: compose, exec, tty, cron, jenkins

docker-compose exec allocates a pseudo-TTY by default, so running it piped, in cron, Jenkins, or any non-interactive context crashes with ValueError: file descriptor cannot be a negative integer (-1) and returns -1. Adding -T disables the TTY and fixes it for most cases, though commands that read stdin can then hang. When -T hangs or fails, fall back to plain docker exec against the container name or ID from docker ps.
