我正在尝试将 python cmd 库与 docker 结合使用。
This is my minimal command class setup.
class Commands(cmd.Cmd):
intro = 'Welcome to the shell.\nType help or ? to list commands.\n'
prompt = 'Shell: '
@staticmethod
def do_stop(arg):
"""
Stops the servers gracefully
:param arg:
:return:
"""
logger.info("Stopping server...")
# Do stuff
如果我在没有 docker 的情况下启动应用程序,shell 就可以正常工作。我可以与它互动,没有问题。但是,如果我使用 docker-compose up,我会收到无限循环的错误消息,如下图所示。
我的应用程序 main.py 如下所示:
if __name__ == "__main__":
Commands().cmdloop()
为什么 docker 抱怨语法未知?是写到标准输出或标准错误的东西,我不知道吗?
