Consider this issue.py file: Executing python issue.py manually yields what I expect: However, if I execute this inside a Docker container, something weird happens: How can I fix this, to make Docker respect the correct output order? Notes: This problem also happens with stderr, although the above MCVE does not show it. The MCVE uses the python image directly but