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

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

问题描述

我正在看一个教程,以对我的django应用程序进行docker化.我不明白为什么我们在 DockerFile 中使用 PYTHONUNBUFFERED 作为环境变量.

可以帮忙吗?

解决方案

PYTHONUNBUFFERED 设置为非空值可确保将python输出直接发送到终端(例如,您的容器日志)而无需先缓冲,您可以实时查看应用程序的输出(例如django日志).

这还可以确保没有部分输出保存在某处的缓冲区中,并且在Python应用程序崩溃时不会写入任何内容.

参考:

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:

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

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