Cleaning Up Docker
With the passage of time running Docker in development, we tend to accumulate a lot of unused images. Sometimes for testing, research or just trying out fun new stuff. Its always cool to run new software in containers, lights up new possibilities for those of us interested in constantly learning new technologies. Downside is a lot of precious SSD memory occupied with rarely used or unused images, the worse thing is we hardly notice. But the guys at Docker Inc. have done a great task by keeping a track of all things Docker.
Say hello to the system
command, part of the docker management commands and simply awesomeness. The system
command provides info from disk usage to system-wide information, ain’t that cool.
Disk usage using df
command:
Returns something like this,
Notice the Reclaimable
this is the size you can recover, it is calculated by subtracting the size of active images from the size of total images.
Real time events using events
command:
Returns the list of real time events from the server, based on Docker object types.
Formatting output
or simply format the output as JSON
System-wide info using info
command:
Another cool command to get all the system related information is the info command. You will be amazed to see the amount of info you can get.
Remove unused data using prune
command:
Now that we have all the info we need, its cleanup time, but beware against using this command half asleep.
Further we can remove exactly what we want, using any of the following commands, feast you eyes ladies and gents.
All of the above commands will prompt for confirmation, so wash your face with cold water or take a shot of Espresso before issuing any of these ;).
Originally published at HackerNoon
Subscribe to Faizan Bashir
Get the latest posts delivered right to your inbox