11

Docker running on Ubuntu is taking 18G of disk space (on a partition of 20G), causing server crashes. Commands below show that there is a serious mismatch between "official" image, container and volume sizes and the docker folder size.

What causes this and how can I cleanup ?

I already tried docker system prunewhich doesn't help.

du -sh /var/lib/docker

enter image description here

docker system df

docker

du -sh /var/lib/docker/*

enter image description here

du -sh /var/lib/docker/containers/*

enter image description here

Robycool
  • 1,104
  • 2
  • 14
  • 26
  • Does this answer your question? [Why is docker image eating up my disk space that is not used by docker](https://stackoverflow.com/questions/27853571/why-is-docker-image-eating-up-my-disk-space-that-is-not-used-by-docker) – rjdkolb Dec 17 '19 at 12:01
  • Is your `du` command is printing out those PNG files directly? That's very unusual...I'd expect them to print out plain text. Can you replace the images with the actual text output of those commands? Is there application source code that's relevant to this question, or is it just about disk utilization on a Linux host? – David Maze Dec 17 '19 at 12:03

3 Answers3

12

I was having the same problem. I solved my problem by deleting log files

sudo sh -c "truncate -s 0 /var/lib/docker/containers/*/*-json.log"

Link: How to clear the logs properly for a Docker container?

Bora Karaca
  • 436
  • 5
  • 14
4

You have two containers that are eating your storage. Those containers must be running, because you said you already ran docker system prune. Otherwise /var/lib/docker/containers would be empty.

So check why are those two consuming so much. Probably they are logging too much to stdout.

  • indeed, there is quite some logging. "virtual container size" is below 1G though, so I guess the log space of stdout is not included. Is there a way to delete logs in stdout without changing container ? – Robycool Dec 17 '19 at 12:10
  • 1
    you can try to `truncate` the log. If you keep running `du`, you'll see that probably the large file is one named `-json.log`. So just truncating it should do the trick, in fact, I think that once I had to do so, but don't remember exactly, so proceed at your own risk :) –  Dec 17 '19 at 12:16
  • I followed this post to truncate logs (after stopping container) and everything looks fine: https://stackoverflow.com/questions/42510002/how-to-clear-the-logs-properly-for-a-docker-container – Robycool Dec 17 '19 at 12:34
1

docker system prune should clean up old unused layers, I have managed to get lots of disk space back several times with this. Hope it helps.

kkubina
  • 147
  • 2