Let’s say you run a Docker or Dokku on your server and suddenly you find that you have 0 free space left on the disk. Things happen.
Most certanly, Docker may have taken all of the available space. You can even check this by installing
ncdu and running it.
I’m almost sure you will see a lot of occupied GiB in
So here is the command you can run to clean it up.
docker system prune -a -f
It is used to clean up Docker resources on your system:
system: Indicates that you want to perform a system-wide cleanup
prune: Initiates the cleanup process
-a: Removes all unused images, not just dangling ones. Dangling images are those that have no tags associated with them
-f: Forces the cleanup without asking for confirmation. This flag is optional, but including it will automatically confirm the cleanup without requiring user input
So, when you run
docker system prune -a -f, Docker will forcefully remove all unused images on your system, including those with no tags (dangling images).
Be cautious when using the -f flag, as it will not prompt you for confirmation, and you might lose data if you have important, unused images.