How to control podman container log behaviour (ctr.log)

11.7k views Asked by At

My /var ran full, the culprit was /var/lib/containers/storage/overlay-containers/<container-hash>/userdata/ctr.log of my gitlab container, which was 11GB.

I searched the documentation/interwebs in vain for any info on

  1. is it safe to delete the ctr.log (on a running container)?
  2. is there a podman command to manage the log (e.g. clean, keep last x MB or days)?
  3. do the --logdriver and --logopt options to podman-run control/affect ctr.log, or is this some extra log?
  4. if (through (3)) I can turn off logging, would I still see logs when attaching to the running container?

Regarding (1) it appears the answer is "yes", deleting ctr.log and restarting the container just made a new ctr.log.

1

There are 1 answers

1
Paul V On

This is not an answer to 1,2,3 or 4 but it prevents filling the disk space which seems the objective of the question.

see https://www.suse.com/support/kb/doc/?id=000019954

Create or edit /etc/containers/containers.conf for podman running as root, or $HOME/.config/container/containers.conf for root-less containers, to contain "log_size_max=SIZE" in the [containers] section, with SIZE being the maximum size in bytes for the log files. For example:

[containers]
log_size_max=10485760

to set a maximum log size of 10 MiB. Afterwards, restart all containers to activate the change.