且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Docker中的Python登录

更新时间:2023-12-05 13:47:52

您已指定文件'error.log'在命令 logging.basicConfig(filename = error.log,level = logging.DEBUG)中用于 logger 将您的日志放入。此文件位于容器内部,并且由于容器是无状态的,因此必须在关闭容器电源后将日志文件安装在本地计算机中的某个位置才能访问。您可以阅读以了解更多信息。

You have specified file 'error.log' in command logging.basicConfig(filename="error.log", level=logging.DEBUG) for logger to put your logs into. This file is located inside your container and since containers are stateless, you have to mount the log file somewhere in your local machine in order to have access after powering off your container. You can read this for more information.

顺便说一句,如果您想在日志文件已经打开的情况下对其进行访问,则可以使用Docker的 exec 选项通过该容器制作一个交互式外壳并找到日志:

BTW, if you want to access the log file while it's already up, you can use exec option of the docker to make an interactive shell through the container and find the logs:

docker exec -it ${container_name}

文档将对于 exec 命令行选项很有帮助。

This documentation will helpful for exec commandline option.