docker 文件中 PYTHONUNBUFFERED 的用途是什么? [英] What is the use of PYTHONUNBUFFERED in docker file?

查看:36
本文介绍了docker 文件中 PYTHONUNBUFFERED 的用途是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在观看一个 dockerize 我的 django 应用程序的教程.我不明白为什么我们在 DockerFile 中使用 PYTHONUNBUFFERED 作为环境变量.

I was watching a tutorial to dockerize my django application. I did not understand why we use PYTHONUNBUFFERED as environment variable in DockerFile.

你能帮忙吗?

推荐答案

PYTHONUNBUFFERED 设置为非空值可确保 python 输出直接发送到终端(例如您的容器日志)而不是第一个缓冲并且您​​可以实时查看应用程序的输出(例如 django 日志).

Setting PYTHONUNBUFFERED to a non empty value ensures that the python output is sent straight to terminal (e.g. your container log) without being first buffered and that you can see the output of your application (e.g. django logs) in real time.

这也确保没有部分输出保存在某个缓冲区中,并且在 python 应用程序崩溃的情况下永远不会写入.

This also ensures that no partial output is held in a buffer somewhere and never written in case the python application crashes.

参考资料:

这篇关于docker 文件中 PYTHONUNBUFFERED 的用途是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆