Docker 打包 Python 需要设置 PYTHONUNBUFFERED 吗?
文章目录
Python 中的 PYTHONUNBUFFERED 环境变量是干嘛的?
下面是一个常见的 dockerfile ,其中有一行 ENV PYTHONUNBUFFERED 1,我都是无脑加上的,但是不知道不加会有什么后果!
FROM python:3.9-buster
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
COPY requirements.txt /code/
RUN (/usr/local/bin/python -m pip install --upgrade pip -i https://mirrors.aliyun.com/pypi/simple) && (pip install -i https://mirrors.aliyun.com/pypi/simple -r requirements.txt)
COPY . /code/看了和这个文章:Python环境变量PYTHONUNBUFFERED
对于3.7以上版本: 标准输出stdout和标准错误stderr全部采用unbuffered
Changed in version 3.7: The text layer of the stdout and stderr streams now is unbuffered.
只要是 version > 3.7 就不需要加了 PYTHONUNBUFFERED 了
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论