mikeizbicki / cmc-csci143

big data course materials
40 stars 76 forks source link

Docker error "The input device is not a TTY" #450

Closed GusAlbach closed 8 months ago

GusAlbach commented 9 months ago

Hi,

I'm receiving the error "The input device is not a TTY" when github runs the workflows. This is the case having already fixed what I thought was the main issue with file pathing in the .github/workflows/tests.yml file. The main suggestion online recommend removing the -it flag from the line

 docker-compose exec pg ./run_tests.sh

,but no such flags exist. Is anyone else having this problem? I'm worried it might be related to a mistake I made when setting up docker. Below is the output right before and when I get the error message

Creating pagila-hw_pg_1 ... done
CONTAINER ID   IMAGE          COMMAND                  CREATED                  STATUS                  PORTS      NAMES
d252b0d44496   pagila-hw_pg   "docker-entrypoint.s…"   Less than a second ago   Up Less than a second   5432/tcp   pagila-hw_pg_1
the input device is not a TTY
Error: Process completed with exit code 1.
tylerheadley commented 9 months ago

Hi Gus,

I had this problem too initially, you actually need to add the flag -T to the command. According to ChatGPT:

The -T flag in the docker-compose exec command is used to disable pseudo-TTY allocation. When you execute a command in a Docker container using docker-compose exec, Docker by default allocates a pseudo-TTY (terminal) for the process running inside the container. This is done to allow interactive processes, such as running a shell, to work properly.

However, in some cases, especially when running non-interactive commands or scripts, you may not want to allocate a TTY. This is where the -T flag comes into play. By using the -T flag, you explicitly instruct Docker to disable the pseudo-TTY allocation, even if the command you're running is non-interactive.

Here's an example of using docker-compose exec with the -T flag:

$ docker-compose exec -T [service_name] [command]

I think this will fix your issue.