Cleaning your ubuntu machine after running docker
Commands I use to cleanup and free memory after running docker
Docker is an awesome piece of technology to learn and use. You can run databases, servers, clients, basically whatever you want, and the nicest part is that you don’t have to install anything on your machine, since the programs will be running inside a container.
But I frequently get warnings saying my memory is running low, which is a trade-off cost of using docker for development purposes. So, digging through the internet, I found a set of commands that help me cleanup my machine after I run docker and create lots of docker volumes during a period of time.
docker system prune -a
docker system prune --all --volumes --force
find /var/lib/docker/containers/ -type f -name "*.log" -delete
Then I can restart the container:
docker-compose down && docker-compose up -d
Bonus Tip
In this simple yet amazing article there are step for investigating which parts of your computer are taking a lot of memory, so then you can go and free some space yourself.
The steps are basically:
sudo du -h --max-depth=1
// cd into big directories
// run ls -l to see which files are using space
Good lucky saving some space! 🤗