Recently I wanted to run a MySQL Docker container and encountered a tragical error:
simple_db | 2021-03-25 10:54:04+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
I was really surprised while reading this one, because the container was working well minutes before. After reading the documentation, and searching on the web for more info, nothing worked for me: the container would not run.
I decided to check for docker-compose updates with my package manager, and guess what? No more space on my root partition 😫
Everybody who played around with Linux distro had one day this view:
How to free disk space on Linux? I will try to show a couple of ways I managed to free space on my root partition.
As I am running on Archlinux, my package manager might be different as yours (ie. I use
aptso be carefull).
The first thing I did was to clear my pacman cache, because I knew it would free some space for sure:
sudo pacman -Scc
With that I cleared almost 30G of data on my disk:
Yeah, freeing 30G is pretty satisfying, but imagine freeing more. Joking. But imagine anyway.
I use Docker a lot, especially while working for school projects or CTFs, so I thought about checking my images and trying to free some more space.
sudo docker images I realized I needed to clean those. I mean, there was like 100 images that I do not use anymore (yes, InterIUT challenges, I talk about you 🥲 ).
sudo docker images prune
This freed 2G on the disk, I was happy about that, but I saw that Docker was still taking too much space here, like 15G could be saved. I realized that Docker volumes where still there, and I decided to remove them.
sudo docker volume prune
Leading me with a total of 40G freed in minutes!
While troubleshouting my disk usage, I used this command to sort by usage:
sudo du / -x -d 1 | sort -n
You can then investigate which directory is taking most usage on your disk.