Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restrict Docker container logs size to a predefined value

Tags:

docker

What is the default log rotation strategy used by Docker for container logs.

How I can restrict the docker container log size to be max 1g and rotate if the size goes bigger.

like image 428
Ijaz Ahmad Avatar asked Sep 11 '25 13:09

Ijaz Ahmad


1 Answers

AFAIU,

Using docker run -
--log-opt max-size=1g

using compose -

logging:
  options:
    max-size: 1g

Also, you can set it globally by updating daemon config, generally /etc/docker/daemon.json (Thanks @Stan for suggestion)

Ref - https://docs.docker.com/config/containers/logging/configure/#limitations-of-logging-drivers

like image 83
vivekyad4v Avatar answered Sep 13 '25 03:09

vivekyad4v