在Docker中运行时如何查看Flask中的记录器信息

时间:2019-08-01 02:03:08

标签: docker flask

我必须在Centos7的docker中运行flask应用程序。现在我遇到了一些问题,但是无论在本地还是在AWS上,我都只能在docker中运行flask应用程序。那么在哪里可以找到记录器信息?

有我的config.py:

import os
base_path = "/opt/cv_parser_data"

port = os.getenv('PORT', 3000)

store_dir_prefix = "%s/cv_store/" % base_path

log_path = "%s/log/" % base_path

tmp_file_path = "%s/tmp_file/" % base_path

2 个答案:

答案 0 :(得分:0)

使用此命令:

admins-MacBook-Pro:~ admin$ sudo npm i -g @angular/cli@latest npm ERR! path /usr/local/bin/ng npm ERR! code EEXIST npm ERR! Refusing to delete /usr/local/bin/ng: ../lib/node_modules/angular-cli/bin/ng symlink target is not controlled by npm /usr/local/bin npm ERR! File exists: /usr/local/bin/ng npm ERR! Move it away, and try again. npm ERR! A complete log of this run can be found in: npm ERR! /Users/admin/.npm/_logs/2019-08-01T03_26_03_978Z-debug.log admins-MacBook-Pro:~ admin$ npm install npm WARN saveError ENOENT: no such file or directory, open '/Users/admin/package.json' npm WARN enoent ENOENT: no such file or directory, open '/Users/admin/package.json' npm WARN admin No description npm WARN admin No repository field. npm WARN admin No README data npm WARN admin No license field. up to date in 1.274s found 0 vulnerabilities admins-MacBook-Pro:~ admin$ sudo npm install npm WARN saveError ENOENT: no such file or directory, open '/Users/admin/package.json' npm WARN enoent ENOENT: no such file or directory, open '/Users/admin/package.json' npm WARN admin No description npm WARN admin No repository field. npm WARN admin No README data npm WARN admin No license field. up to date in 1.199s found 0 vulnerabilities docker logs flask_container_id

希望获得帮助!

答案 1 :(得分:0)

如果没有docker,您的日志没有打印到stdout,那么有了docker,它们也不会被打印到stdout,那么您就无法使用docker logs看到它。

如果是上述情况,则必须进入容器以查看日志,请参见this

对于您的情况,您提到了log_path = "%s/log/" % base_path,很多人都输入了next,然后cd进入上方的文件夹以查看日志。

docker exec -it $your_container_name /bin/bash