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.
To set log limits for containers on a host --log-opt can be configured with max-size and max-file so that a containers logs are rolled over when they reach a max limit and only a certain number of files are saved before being discarded. Hope this helps!
You can run the command kubectl exec -it <container_name> bash and use the command line inside the container to change the environment variable . You can do it by running the command export LOG_LEVEL=debug or export LOG_LEVEL=error inside the container.
Viewing Container Logs You can use docker ps -a to get the IDs and names of your containers. The logs command prints the container's entire log output to your terminal. The output will not be continuous. If you'd like to keep streaming new logs, add the --follow flag to the command.
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
For a quick config example, something like
version: '3'
services:
postgres:
image: postgres:9.6
logging:
driver: none
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With