How to limit log file size for podman containers ?

Solution In Progress - Updated -

Environment

  • Red Hat Enterprise Linux 8
  • Red Hat Enterprise Linux 9
  • podman

Issue

  • podman container logs fills up the file system and needs a way to limit the size of the log file

Resolution

  • containers.conf needs to be edited to include the below line under "[containers]" section
log_size_max=<SIZE>

where SIZE should be mentioned in bytes which defines the maximum size for the container log file
- Negative numbers indicate that no size limit is imposed. If it is positive, it must be >= 8192 to match/exceed conmon's read buffer. The file is truncated and re-opened so the limit is never exceeded.
- After making the changes, it is recommended to run #podman system migrate, this will make sure you have the changes reflected

Note:
- containers.conf is present under /etc/containers for root and should be present under ~/.config/containers/ for rootless users. The file can be created if not already present.

P.S:
- Please note that running #podman system migrate at any point will cause the running containers to stop and it may need to be started manually.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments