docker exec 上的 Heredoc

Heredoc on docker exec

我基本上是在尝试让 Flask-migrate 的 shell 和 Flask 应用上下文

执行 heredoc

下面是我在 bash 脚本

中尝试 运行 的命令
$ docker exec -it mycontainer ./manage shell <<-EOF
    # shell commands to be executed
EOF

尝试执行上述命令时,我得到:

cannot enable tty mode on non tty input

这是管理文件:

#!/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()

我的问题是有没有办法将 heredoc 中的命令集传递给 shell?

docker exec 命令中删除 -t 选项以删除附加的 pseudo-TTY 或使用 --tty=false:

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

否则:

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