Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heredoc on docker exec

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?

like image 221
lozadaOmr Avatar asked Jan 10 '16 09:01

lozadaOmr


People also ask

How do I run multiple commands in Docker compose?

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.


1 Answers

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
like image 125
anubhava Avatar answered Sep 24 '22 12:09

anubhava