Howto delete logs from MB Virtual Machine?

virtualmachine
log
Tags: #<Tag:0x00007fe3d073e608> #<Tag:0x00007fe3d073e4c8>

#1

The logs in my MB Virtual Machine gets longer and longer with
docker-compose logs

How can I delete one specific (or all the) logs?


#2

Docker provides options for log rotation. See this question on Stack Overflow:

I think to use this with docker-compose it needs to be set in the compose.yml as described at https://docs.docker.com/compose/compose-file/#/logging

Something like this should probably do for having maximum 10 log files with 10MB each (have never tried it myself):

logging:
  driver: json-file
  options:
    max-size: 10m
    max-file: 10

Would be nice to have this set in the official VM right from the start :smiley:


#3

Thank you very much @outsidecontext !

Do I have to add this logging: section to every existing section in the file docker-compose.yml?
(Once for ‘search’, once for ‘musicbrainz’, once for ‘postgresql’ and so on)? Or just as one single addition at the end of the file?


#4

“PRs welcome” :wink:

(I just took a look, but I couldn’t figure out where it should go at a glance. In the Vagrantfile maybe?)


#5

Yes, I think so. Don’t know if there is a way to set it globally.

It’s in https://github.com/mayhem/musicbrainz-docker/blob/master/docker-compose.yml :slight_smile: Let’s see if it works for @InvisibleMan78, if it does someone can open a PR :wink:


#6

I would tell you if it works, but how can I test it?
I can add your code snippet to every section, save the file and restart everything.

But how can I be sure if it doesn’t create more then 10 log files and each not bigger then 10 MB?

And BTW:
This doesn’t solve my initial problem. Even with 10 logfiles à 10MB the startup-process showing all my previous replication steps and all my local search attempts spend already several minutes until the scrolling stops :smirk:


#7

If this scrolling is still about the logs you can of course reduce the logs even more or disable them completely (driver: none). If it is not about the logs, well, at least you have fixed the log file size issue :smiley:


#8

Unfortunately I get the following error for every section using the command
docker-compose start
ERROR: Validation failed in file './docker-compose.yml', reason(s):
Unsupported config option for indexer: 'driver'
Unsupported config option for musicbrainz: 'driver'
...

Any other ideas?


#9

I just realized the docker-compose.yml is a v1, not a v2 file. In that case the syntax is a bit different, the snippet below does the same as above, but different configuration keys for v1 compose files:

log_driver: json-file
log_opt:
  max-size: 10m
  max-file: 10