In the middle of the desert you can say anything you want

06 Jun 2023

Docker unbuffered python output to read logs live

Docker image runs a Python script that uses print() a lot, but docker logs is silent because python print() uses buffered output, and it takes minutes to show.

Solution1: tell python not to do that through an environment variable.

docker run --name=myapp -e PYTHONUNBUFFERED=1 -d myappimage

  1. Python app does not print anything when running detached in docker - Stack Overflow ↩︎

Nel mezzo del deserto posso dire tutto quello che voglio.