Thursday, April 18, 2024

Disk usage on windows

 On windows it is bit cumbersome to find the space/storage usage of each folder. To get the space used by each folder, download the disk usage utility from here. Example command that can be use to find the usage:

du.exe" -l 2 c:\Users\<user name>\AppData\Local\Docker

Docker Desktop taking up storage space on windows, Configuring log rotation

Docker desktop by default is not configured with log rotation. Because of this you will run out of disk space. This document will help with debugging, cleanup and configuring log rotation. Logs contain both docker daemon logs and container logs. Limiting the size and the number of log files is part of the log rotation.

To figure out what your logging driver is, run the below:

$ docker info --format '{{.LoggingDriver}}'

On windows, logs can be found typically in:

daemon logs -  %LOCALAPPDATA%\Docker\log\vm\dockerd.log
containerd logs - %LOCALAPPDATA%\Docker\log\vm\containerd.log

For configuring docker daemon logs

Find (or create) the below file:

OS and configuration File location
Linux, regular setup /etc/docker/daemon.json
Linux, rootless mode ~/.config/docker/daemon.json
Windows C:\ProgramData\docker\config\daemon.json

Contents of daemon.json:

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

Restart docker desktop from the system tray order the desktop itself.

For configuring docker container logs

You can set the logging driver for a specific container by using the --log-driver flag to docker container create or docker run:

docker run \
      --log-driver json-file --log-opt max-size=10m \
      alpine echo hello world