Skip to content

Instantly share code, notes, and snippets.

@athlan
Created January 16, 2024 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save athlan/0f475846bc5e14cc4e59565b887f1b5e to your computer and use it in GitHub Desktop.
Save athlan/0f475846bc5e14cc4e59565b887f1b5e to your computer and use it in GitHub Desktop.
Diagnose docker container size

Sometimes there's a problem where containers taking up all space. The following checklist helps with diagnosing what is the root cause of that.

  1. Basic commands to check docker status and consumed size
docker system df
docker system df -v
docker container ls -s
  1. Check docker container log size
container=34443add1c1c
du -h $(dirname $(docker inspect "$container" --format '{{ .LogPath }}'))

If this folder contains large files, most likely container produces massive amount of logs on stdout. A simple solution is to review what's being logger or set a cap to limit log files, for example in docker-compose:

    logging:
      driver: "json-file"
      options:
        max-size: "100m"
        max-file: "10"
  1. Check docker container diff folder (whether there's any additional file structure on writable layer)
du -h $(dirname $(docker inspect "$container" --format '{{ .GraphDriver.Data.MergedDir }}'))/diff

References:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment