7

Docker Madness - When The Output Order of Debugging Seems Impossible

 3 years ago
source link: https://fuzzyblog.io/blog/docker/2020/07/31/docker-madness-when-the-output-order-of-debugging-seems-impossible.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Docker Madness - When The Output Order of Debugging Seems Impossible

Jul 31, 2020

IMG_3775.jpeg

Yesterday I was stuck in a hellish debugging cesspool – you know what I mean – when you are debugging a mysterious crash right down embedding line by line print statements and nothing is making sense. And I don't mean that its not making a lot of sense; I mean that its making NO DAMN SENSE. I was debugging on a GPU instance on AWS that was running a TensorFlow application and what I kept seeing was output appearing before the routine invoking it was executing. And this was a worst case scenario right down to the very first line of my Python code being:

print("AT START")

Happily I was pairing with my colleague Grant and he did that wonderful pairing step of "this makes no damn sense; let me apply my Google Fu to this" and he discovered that Docker buffers output at times and he recommend this change to the Dockerfile:

Before:

# rest of Dockerfile appears here
CMD [ "python3", "./main.py" ]

After:

# rest of Dockerfile appears here
CMD [ "python3", "-u", "./main.py" ]

Here is the relevant Stack Overflow post.

Thank you Grant!


Posted In: #docker #python


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK