Low on disk space, cleaning up old Docker containers

(John Arce) #1

I’m now getting 70% disk space

Usage of /:   70.4% of 39.25GB  

I tried this command du | sort -rn | head

Let me know your thoughts and how can I cleanup my disk.

john@discourse:/# du | sort -rn | head
30332308	.
26911916	./var
25919260	./var/lib
25651820	./var/lib/docker
25581776	./var/lib/docker/aufs
24242456	./var/lib/docker/aufs/diff
1339072	./var/lib/docker/aufs/mnt
1338828 ./var/lib/docker/aufs/mnt/4bd7749b00a950fd265d031cfb48dc173aa526e8aba6035f845fdca975025c5a
947748	./usr
712200	./var/lib/docker/aufs/diff/bf95185ac9b9af59b5a63966ee56fa38ce9ac0dabebad0eb63e59c2de46d16d3
4 Likes
(Sam Saffron) #2

This will reliably clean up old Docker images, as well as any old Ubuntu updates:

apt-get autoclean
apt-get autoremove
cd /var/discourse
./launcher cleanup

I just fixed up cleanup so it is a lot less random, it uses docker-gc by spotify which has much less problems.

44 Likes
Configure automatic backups for Discourse
Digital Ocean hosting: Do I need a system admin?
(Jeff Atwood) #33

Strongly related to this, I find that Ubuntu disk space is eaten up heavily by keeping old kernels around. Here’s a Ubuntu 14.04 LTS DO droplet from fall 2014:

Before:

Filesystem     1M-blocks  Used Available Use% Mounted on
/dev/vda           30110 16428     12131  58% /

Do this:

apt-get autoclean
apt-get autoremove

(this can take a while, maybe 5 minutes? it has to iterate through all the old kernels and remove all of them.)

After:

Filesystem     1M-blocks  Used Available Use% Mounted on
/dev/vda           30110 10530     18029  37% /

That removes 6GB of just old archived Linux kernels! At the end of this, it’s very clean, all the disk space is taken by

  1. /var/lib/docker/aufs 7GB
  2. swapfile (recommended 2GB on a 1GB RAM droplet)
13 Likes
(Jeff Atwood) #39

On a brand new clean install of Discourse on a 20GB Digital Ocean droplet, I see this disk usage:

Filesystem     1M-blocks  Used Available Use% Mounted on
/dev/vda1          30108  6079     22478  22% /
none                   1     0         1   0% /sys/fs/cgroup
udev                 487     1       487   1% /dev
tmpfs                100     1       100   1% /run
none                   5     0         5   0% /run/lock
none                 497     1       497   1% /run/shm
none                 100     0       100   0% /run/user

So consider that (4GB – includes 2GB of swapfile in this case) the absolute minimum amount of disk space Discourse will use

11 Likes
(xiasummer) #97

I also find there being not enough space.
But found it so strange that there are so many “none” item, what is that? And is it possible to cleanup such space?

# df -h

Filesystem      Size  Used Avail Use% Mounted on
udev            487M  4.0K  487M   1% /dev
tmpfs           100M  1.5M   98M   2% /run
/dev/vda1        20G   13G  5.4G  71% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
none            5.0M     0  5.0M   0% /run/lock
none            497M  2.5M  495M   1% /run/shm
none            100M     0  100M   0% /run/user
none             20G   13G  5.4G  71% /var/lib/docker/aufs/mnt/aab561dca2fec40e8c8d0dca9b27261e947f8e7cc4865fb8d11efd42584e631a
none             20G   13G  5.4G  71% /var/lib/docker/aufs/mnt/21dc2b95807397afafa9c7ceff8b45de217c210eb16c00ecfd5d39228b78763b
none             20G   13G  5.4G  71% /var/lib/docker/aufs/mnt/7c578ba7383b1be9d612c1ffe25c6a9850656194cb789a24d0a6d40177b7b28a
shm              64M     0   64M   0% /var/lib/docker/containers/abde6e9e4a25482ee1f60033e124691c88046369449734139e431c538c86fc52/shm
shm              64M     0   64M   0% /var/lib/docker/containers/18d7cc386a10ad7cc05123d9f8a4fe53279d2e625a30f169ad9a994be4e9f11a/shm
shm              64M     0   64M   0% /var/lib/docker/containers/ce0c1771844e3f2bda150db5cffe1f5af0950e7e00ba1060e01b2b671d7f055c/shm
none             20G   13G  5.4G  71% /var/lib/docker/aufs/mnt/8290b03b4f302b6c9fe3aa8541d41f7400a661dbaa4c0920bcf593cb5b225a33
shm             512M  8.0K  512M   1% /var/lib/docker/containers/7aab317f92c6f14f6537c45e0f1806db90fe21ce2eb00ced3e30632b1990b042/shm

Going on, I tried the space in /var/

/var# du | sort -rn | head
13043068        .
6891272 ./lib
6652364 ./lib/docker
6633844 ./lib/docker/aufs
3808864 ./log
3610276 ./lib/docker/aufs/diff
3023464 ./lib/docker/aufs/mnt
2611684 ./lib/docker/aufs/mnt/8290b03b4f302b6c9fe3aa8541d41f7400a661dbaa4c0920bcf593cb5b225a33
1988636 ./lib/docker/aufs/diff/9326d0dccfb0babdd682226f4e8e95f3ef0856e538df3f4afd243a6cfad69729
1858296 ./discourse

I feel strange about the folder /docker/aufs and /log
Why /log takes 3.8 G of space? Can I delete it?

About the /docker/aufs/ folder

/var/lib/docker/aufs # du | sort -rn | head
6633872 .
3610288 ./diff
3023480 ./mnt
2611684 ./mnt/8290b03b4f302b6c9fe3aa8541d41f7400a661dbaa4c0920bcf593cb5b225a33
1988636 ./diff/9326d0dccfb0babdd682226f4e8e95f3ef0856e538df3f4afd243a6cfad69729
1503308 ./mnt/8290b03b4f302b6c9fe3aa8541d41f7400a661dbaa4c0920bcf593cb5b225a33/var
1419880 ./mnt/8290b03b4f302b6c9fe3aa8541d41f7400a661dbaa4c0920bcf593cb5b225a33/var/www
1419868 ./mnt/8290b03b4f302b6c9fe3aa8541d41f7400a661dbaa4c0920bcf593cb5b225a33/var/www/discourse
1006032 ./diff/9326d0dccfb0babdd682226f4e8e95f3ef0856e538df3f4afd243a6cfad69729/var
968896  ./mnt/8290b03b4f302b6c9fe3aa8541d41f7400a661dbaa4c0920bcf593cb5b225a33/usr

Why is diff folder this big, can I delete it? some folder are 2 years old, can I delete them?

(Jeff Atwood) #98

Just run ./launcher cleanup as stated earlier.

2 Likes