Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker log don't show python print output

I have a Django Proj running in Docker Container

My Debug=True

but docker up logging doesn't show any print('xxxx') output.

Is there a way to fix it? thanks!

like image 658
C.K. Avatar asked Jun 12 '26 23:06

C.K.


1 Answers

After a long search I found this https://serverfault.com/a/940357

Add flush=True

print(datetime.now(), flush=True)

Or add PYTHONUNBUFFERED: 1 to docker-compose.yml which is added by PyCharm by default

version: '3.6'

services:

  test:
    ....
    environment:
      PYTHONUNBUFFERED: 1  # <---
    ....
like image 58
C.K. Avatar answered Jun 14 '26 12:06

C.K.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!