14

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

2
  • Does this answer your question? Why is docker image eating up my disk space that is not used by docker
    – rjdkolb
    Dec 17, 2019 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, 2019 at 12:03

3 Answers 3

14

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?

1
  • Lifesaver. Surprisingly hard answer to come by. Jul 12, 2022 at 11:23
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.

3
  • 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, 2019 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 <CONTAINER_ID>-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 :)
    – user4093955
    Dec 17, 2019 at 12:16
  • I followed this post to truncate logs (after stopping container) and everything looks fine: stackoverflow.com/questions/42510002/…
    – Robycool
    Dec 17, 2019 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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.