Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

By default there are no Docker does not rotate logs of the containers. This might cause disk space issues when there is something that is intensively logging.

Table of Contents

Globally

You can set a limit in the /etc/docker/daemon.json file. Afterwards restart docker

Code Block
languagejs
title/etc/docker/daemon.json
{
  "log-driver": "json-file",
  "log-opts": {"max-size": "10m", "max-file": "3"}
}

Docker Compose

It is also possible to set this via the docker compose configuration.

Code Block
languageyml
titledocker-compose.yml
version: '3'

services:
  my_service:
    logging:
      driver: "json-file"
      options:
        max-size: "5m"

Clearing logs manually

Running truncate -s 0 /var/lib/docker/containers/*/*-json.log will clear ALL logs.

...