'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:[1]
For a quick config example, something like
version: '3'
services:
postgres:
image: postgres:9.6
logging:
driver: none
Solution 2:[2]
Not exactly what is asked, but as of September 2021 (on Compose V2), the --attach parameter allows to select the services to listen to.
For example docker compose up --attach your-service will only display logs for your-service.
Solution 3:[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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | funnydman |
| Solution 2 | |
| Solution 3 | funnydman |
