Disable logging for one container in Docker-Compose
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.
Solution 1:
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
Solution 2:
For a quick config example, something like
version: '3'
services:
postgres:
image: postgres:9.6
logging:
driver: none
Solution 3:
As the second option, you may be interested in not fully removing logging (what 'none' value does), but in storing logs of some services in syslog, there is the driver for it, for instance:
certbot:
image: certbot/certbot
restart: unless-stopped
logging:
driver: "syslog"
Note that the syslog daemon must be running on the host machine. To see the logs use for example: journalctl -n 100 --no-pager