I have a web application launched using Docker compose that I want to disable all logging for (or at the very least print it out to syslog instead of a file).
When my web application works it can quickly generate an 11GB log file on startup so this eats up my disk space very fast.
I'm aware that normal docker has logging options for its run command but in Docker Compose I use
docker-compose up
in the application folder to start my application. How would I enable this functionality in my case? I'm not seeing a specific case anywhere online.
Note: As of Compose V2 (replacing V1 in April 2022) this answer will no longer work. V2+ should use the attach
attribute in Nick Vee's answer or the ---no-attach
flag similar to Kipr's answer.
You should be able to use logging feature. Try to set driver to none
logging:
driver: none
Full example:
services:
website:
image: nginx
logging:
driver: none
In recent versions of docker-compose, if all of the services have disabled logging, docker-compose will act as in detach mode. To force the attached mode you can add a simple silent service like that:
services:
website:
image: nginx
logging:
driver: none
force-attach:
image: bash
command: tail -f /dev/null