Docker Compose Exec on Github Actions

Just hit this error running a Github Action that used docker compose exec ...:

the input device is not a TTY

Github actions doesn’t give you a true terminal or shell (input/output environment, a TTY) and docker compose exec by default does, essentially, docker exec -it ... where -i means interative and -t is run a TTY (input/output device).

To avoid the error use the -T flag:

docker compose exec -T containerName commandHere

There’s some tickets floating around that suggest putting COMPOSE_INTERACTIVE_NO_CLI=1 in the environment, but that’s deprecated in v2.