码头工人文件中PYTHONUNBUFFERED的用途是什么? [英] What is the use of PYTHONUNBUFFERED in docker file?
问题描述
我正在看一个教程,以对我的django应用程序进行docker化.我不明白为什么我们在 DockerFile 中使用 PYTHONUNBUFFERED
作为环境变量.
可以帮忙吗?
将 PYTHONUNBUFFERED
设置为非空值可确保将python输出直接发送到终端(例如,您的容器日志)而无需先缓冲,您可以实时查看应用程序的输出(例如django日志).
这还可以确保没有部分输出保存在某处的缓冲区中,并且在Python应用程序崩溃时不会写入任何内容.
参考:
- https://docs.python.org/3/using/cmdline.html#envvar-PYTHONUNBUFFERED
- https://alphacoder.xyz/dockerizing-django/
- https://towardsdatascience.com/how-to-contain-your-first-django-in-docker-and-access-it-from-aws-fdb0081bdf1d
I was watching a tutorial to dockerize my django application. I did not understand why we use PYTHONUNBUFFERED
as environment variable in DockerFile.
Can you please help?
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.
This also ensures that no partial output is held in a buffer somewhere and never written in case the python application crashes.
Refs:
- https://docs.python.org/3/using/cmdline.html#envvar-PYTHONUNBUFFERED
- https://alphacoder.xyz/dockerizing-django/
- https://towardsdatascience.com/how-to-contain-your-first-django-in-docker-and-access-it-from-aws-fdb0081bdf1d
这篇关于码头工人文件中PYTHONUNBUFFERED的用途是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!