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?
We can also use the | operator to run multiple commands in Docker Compose. The syntax of the | operator is a bit different from the && operator. Here, we added the commands on separate lines. Everything is the same except for the command instruction.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With