docker-compose exec python the input device is not a TTY in AWS EC2 UserData

Abdennour TOUMI picture Abdennour TOUMI · Apr 9, 2018 · Viewed 7.7k times · Source

I am using EC2 UserData to bootstrap the instance.

TRacking log of bootstrap execution /var/log/cloud-init-output.log, I found that the script was stopped at :

+ docker-compose exec web python /var/www/flask/app/db_fixtures.py
the input device is not a TTY

It seems like this command it's running in interactive mode, but why ? and how to force noninteractive mode for this command (docker-compose exec) ?

Answer

Yuankun picture Yuankun · Apr 9, 2018

Citing from the docker-compose exec docs:

Commands are by default allocating a TTY, so you can use a command such as docker-compose exec web sh to get an interactive prompt.

To disable this behavior, you can either the -T flag to disable pseudo-tty allocation:

docker-compose exec -T web python /var/www/flask/app/db_fixtures.py

Or set the COMPOSE_INTERACTIVE_NO_CLI environment variable to 1 before running docker-compose exec:

export COMPOSE_INTERACTIVE_NO_CLI=1