Categories
Python Answers

How to fix Python app does not print anything when running detached in Docker?

Spread the love

Sometimes, we want to fix Python app does not print anything when running detached in Docker.

In this article, we’ll look at how to fix Python app does not print anything when running detached in Docker.

How to fix Python app does not print anything when running detached in Docker?

To fix Python app does not print anything when running detached in Docker, we run python with the -u flag in our Dockerfile.

For instance, we write

CMD ["python","-u","main.py"]

to run main.py with -u to use unbuffered output.

conclusion

To fix Python app does not print anything when running detached in Docker, we run python with the -u flag in our Dockerfile.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *