How to fix Error response from daemon: error reading log file: file size exceeds limit in Docker

DockerBEGINNERMEDIUMUpdated Dec 6, 2025ยท 167 views

This error occurs when Docker container logs grow too large because log rotation is not configured. The fix involves configuring the json-file logging driver with max-size and max-file options to enable automatic log rotation.

Quick fix

Fixes Error response from daemon: error reading log file: file size exceeds limit

# List containers with their log paths
docker inspect --format='{{.Name}} {{.LogPath}}' $(docker ps -aq)

# Check log file sizes
sudo du -sh /var/lib/docker/containers/*/*-json.log | sort -h

# Or check a specific container's log size
docker inspect --format='{{.LogPath}}' <container_id> | xargs sudo ls -lh
  1. Identify the problematic container
  2. Clear the current oversized log file
  3. Configure global log rotation in daemon.json
  4. Configure per-container log rotation with docker run
docker โ€” error
# List containers with their log paths
docker inspect --format='{{.Name}} {{.LogPath}}' $(docker ps -aq)
# Check log file sizes
sudo du -sh /var/lib/docker/containers/*/*-json.log | sort -h
# Or check a specific container's log size
docker inspect --format='{{.LogPath}}' <container_id> | xargs sudo ls -lh
Error response from daemon: error reading log file: file size exceeds limit

What this error means

The "error reading log file: file size exceeds limit" error in Docker indicates that a container's log file has grown so large that Docker cannot read it efficiently. This typically happens when using Docker's default json-file logging driver without log rotation configured. By default, Docker's json-file logging driver does not perform any log rotation. Container stdout and stderr output is written to JSON files located in `/var/lib/docker/containers/<container-id>/<container-id>-json.log`. Without limits, these files grow indefinitely until they consume all available disk space. This error commonly appears when trying to view logs with `docker logs` for a container that has been running for a long time and producing significant output. The Docker daemon imposes internal limits on log file reads to prevent memory exhaustion.

Typical symptoms

  • docker logs command fails with 'file size exceeds limit' error
  • Container has been running for extended period without restart
  • Large JSON log files in /var/lib/docker/containers/
  • Disk space gradually consumed by Docker logs
  • docker logs --tail works but full logs fail
  • CI/CD pipelines fail when attempting to retrieve container logs

Common causes

  1. Log rotation not configured for the json-file logging driver
  2. Container generating excessive stdout/stderr output
  3. Long-running containers without periodic restarts
  4. Application logging verbose debug information to stdout
  5. No max-size or max-file options set in daemon.json
  6. Docker Compose services missing logging configuration

How to fix "Error response from daemon: error reading log file: file size exceeds limit"

1Identify the problematic container

First, find which container is generating large logs:

bash
# List containers with their log paths
docker inspect --format='{{.Name}} {{.LogPath}}' $(docker ps -aq)

# Check log file sizes
sudo du -sh /var/lib/docker/containers/*/*-json.log | sort -h

# Or check a specific container's log size
docker inspect --format='{{.LogPath}}' <container_id> | xargs sudo ls -lh

This helps you identify which containers need log rotation configured.

2Clear the current oversized log file

To immediately free up disk space without stopping the container, truncate the log file:

bash
# Get the log file path for your container
LOG_PATH=$(docker inspect --format='{{.LogPath}}' <container_id>)

# Truncate the log file (clears contents but keeps file)
sudo truncate -s 0 "$LOG_PATH"

# Alternative using cat
sudo cat /dev/null > "$LOG_PATH"

Note: This only provides temporary relief. Without configuring log rotation, the file will grow again.

3Configure global log rotation in daemon.json

Set up log rotation for all new containers by editing the Docker daemon configuration:

bash
# Create or edit daemon.json
sudo nano /etc/docker/daemon.json

Add the following configuration:

json
{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "10m",
    "max-file": "3"
  }
}

This limits each log file to 10MB and keeps 3 rotated files (30MB total per container).

Restart Docker to apply the changes:

bash
sudo systemctl restart docker

Important: Existing containers will NOT use the new configuration. They must be recreated.

4Configure per-container log rotation with docker run

When starting containers manually, specify log options:

bash
docker run -d \
  --log-driver json-file \
  --log-opt max-size=10m \
  --log-opt max-file=5 \
  your-image:tag

Common max-size values:
- Development: 10m (10 megabytes)
- Production: 50m-100m
- High-volume logging: 200m with max-file=10

5Configure log rotation in docker-compose.yml

Add logging configuration to each service in your docker-compose.yml:

yaml
version: '3.8'
services:
  app:
    image: your-app:latest
    logging:
      driver: "json-file"
      options:
        max-size: "50m"
        max-file: "5"

  database:
    image: postgres:15
    logging:
      driver: "json-file"
      options:
        max-size: "20m"
        max-file: "3"

After updating, recreate the containers:

bash
docker-compose down
docker-compose up -d
6Recreate existing containers to apply new settings

Existing containers must be recreated to use new log settings:

bash
# For docker-compose
docker-compose down
docker-compose up -d

# For standalone containers, stop and remove, then run with new settings
docker stop <container_id>
docker rm <container_id>
docker run -d --log-opt max-size=10m --log-opt max-file=3 your-image:tag

Verify the new settings are applied:

bash
docker inspect --format='{{.HostConfig.LogConfig}}' <container_id>
7Verify log rotation is working

After recreating containers, verify log rotation is configured:

bash
# Check container's log configuration
docker inspect <container_id> --format='{{json .HostConfig.LogConfig}}' | jq

# Monitor log file sizes over time
watch -n 60 'sudo du -sh /var/lib/docker/containers/*/*-json.log | sort -h'

You should see multiple rotated log files like:
- <container-id>-json.log (current)
- <container-id>-json.log.1 (rotated)
- <container-id>-json.log.2 (rotated)

Advanced notes

Using the local logging driver: Docker recommends the local logging driver for production as it performs log rotation by default and uses a more efficient binary format:

json
{
  "log-driver": "local",
  "log-opts": {
    "max-size": "10m",
    "max-file": "3"
  }
}

Note: The local driver's logs are not in JSON format, so docker logs output format differs slightly.

Centralized logging solutions: For production environments, consider using dedicated logging drivers that ship logs to external systems:
- syslog - System logging daemon
- journald - systemd journal
- fluentd - Forward to Fluentd collector
- awslogs - Amazon CloudWatch Logs
- gcplogs - Google Cloud Logging

Application-level logging: Instead of relying solely on Docker log rotation, consider:
- Configuring your application to rotate its own logs
- Logging to a file volume instead of stdout
- Using structured logging with log levels to reduce volume

Kubernetes environments: If using Docker with Kubernetes, note that kubelet handles log rotation separately. Configure it via the containerLogMaxSize and containerLogMaxFiles kubelet flags.

Compression: The json-file driver supports compression with the compress option:

json
{
  "log-opts": {
    "max-size": "10m",
    "max-file": "5",
    "compress": "true"
  }
}

Windows considerations: On Windows Server, daemon.json is located at C:\ProgramData\docker\config\daemon.json. Docker Desktop for Windows uses a virtual machine, so log paths differ.

Frequently asked questions

What does "Error response from daemon: error reading log file: file size exceeds" mean?
The "error reading log file: file size exceeds limit" error in Docker indicates that a container's log file has grown so large that Docker cannot read it efficiently. This typically happens when using Docker's default json-file logging driver without log rotation configured. By default, Docker's json-file logging driver does not perform any log rotation.
How do I fix "Error response from daemon: error reading log file: file size exceeds"?
This error occurs when Docker container logs grow too large because log rotation is not configured. The fix involves configuring the json-file logging driver with max-size and max-file options to enable automatic log rotation.
What causes "Error response from daemon: error reading log file: file size exceeds"?
Log rotation not configured for the json-file logging driver Container generating excessive stdout/stderr output Long-running containers without periodic restarts
Is the "Error response from daemon: error reading log file: file size exceeds" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading