Home > OS >  How to stop Docker writing logs on host volume?
How to stop Docker writing logs on host volume?

Time:08-05

I have a Pyhton application running inside a Docker container, and I managed to use the logging module to write logs from the application on a file which is saved in a volume shared with the host. However, when I start the application, together with the test messages I write, I can see some other messages which seems to be logs from Docker. Here is how the log file appears after an execution of the application:

DEBUG:debug log test
INFO:info log test
INFO: * Running on all addresses (0.0.0.0)
   WARNING: This is a development server. Do not use it in a production deployment.
 * Running on http://127.0.0.1:5000
 * Running on http://172.17.0.2:5000 (Press CTRL C to quit)

The third message is unwanted. Is it possible to avoid writing this kind of log messages?

CodePudding user response:

Those are not messages from Docker, but from the application. In the Docker logs you see anything that the application writes to "system out".

If you don't want to see these messages you need to redirect the output of the application running in Docker or use a separate logging option inside the application.

  • Related