10

I'm basically trying to have a heredoc be executed by Flask-migrate's shell with Flask app context

Below is the command i'm trying to run inside my bash script

$ docker exec -it mycontainer ./manage shell <<-EOF
    # shell commands to be executed
EOF

When trying to execute the above command I get:

cannot enable tty mode on non tty input

This is the manage file:

#!/usr/bin/env python

from middleware import create_app, config
from middleware.models import db

from flask.ext.script import Manager
from flask.ext.migrate import Migrate, MigrateCommand


app = create_app(config)
migrate = Migrate(app, db)

manager = Manager(app)
manager.add_command('db', MigrateCommand)


if __name__ == '__main__':
    manager.run()

My question is there a way to pass set of commands like in heredoc to the shell?

Cyrus
  • 84,225
  • 14
  • 89
  • 153
lozadaOmr
  • 2,565
  • 5
  • 44
  • 58

1 Answers1

15

Remove -t option from docker exec command to remove attached pseudo-TTY OR use --tty=false:

docker exec -i mycontainer ./manage shell <<-EOF
    # shell commands to be executed
EOF

Or else:

docker exec -i --tty=false mycontainer ./manage shell <<-EOF
    # shell commands to be executed
EOF
anubhava
  • 761,203
  • 64
  • 569
  • 643