我基本上是在尝试让 Flask-migrate 的 shell 与 Flask 应用程序上下文一起执行 heredoc
下面是我试图在我的 bash 脚本中运行的命令
$ docker exec -it mycontainer ./manage shell <<-EOF
# shell commands to be executed
EOF
当尝试执行上述命令时,我得到:
无法在非 tty 输入上启用 tty 模式
这是管理文件:
#!/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
关于python - docker exec 上的 Heredoc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34703985/