List docker log sizes

docker ps -qa | xargs docker inspect --format='{{.LogPath}}' | xargs sudo du -hl

June 18, 2019lockntross

Explanation

docker ps -qa prints all docker container ids:

  • -a makes it print all container ids, instead of the default of only the currently running containers
  • -q makes it omit the header line and print only container ids

xargs docker inspect --format='{{.LogPath}}' runs docker inspect --format='{{.LogPath}}' for each line in the input, in this example for each container id, which then prints the log path of the container.

xargs sudo du -hl runs sudo du -hl for each line in the input, in this example for each container log path, which then prints the disk usage of that path in human readable format (-h).