Something to watch out for: Docker may be using lots of your computer’s disk space. All data is written to a grow-only file. On my mac it was at 27 GB from pretty light Docker experimentation. There is a discussion thread here: Where does Docker keep images/containers so I can better track my disk usage.
This file stores image layers and containers. It grows as more data is created, such as layers created when building a Dockerfile. Each intermediate layer is saved, even if it is no longer needed and is ‘dangling’ or ‘orphaned’. Specifically, the file is a block-storage sparse file. Even if you delete obsolete layers and images the file’s size will not decrease because Docker has no compaction mechanism as of version 1.12.
You can delete exited images and dangling layers with the below commands. You will not get the actual space back, but it should stop growing for a while as the internally-freed space is reused, until Docker hits the current filesize again and expands the storage file again.
docker rm $(docker ps -q -f 'status=exited') docker rmi $(docker images -q -f "dangling=true")
On Macs the file is Docker.qcow2 in ~/Library/Containers/com.docker.docker/ .
There is currently no official solution. Some ideas in the thread include:
- Deleting Docker.qcow2 file and restarting Docker for Mac (or Windows). All images and containers will be deleted! If you’re experimenting and this doesn’t matter much, you’ll be set.
- Move the file to a larger drive and symlink it. This takes pressure off tight SSD space on laptops.
- You can use qemu-img to reclaim space from the file: https://www.jamescoyle.net/how-to/323-reclaim-disk-space-from-a-sparse-image-file-qcow2-vmdk.
Also, there are some Docker environment cleanup tools like docker-gc (from Spotify). Running this regularly should limit growth by removing dead data so the sparse file blocks can be reused. It is a more sophisticated version of the 2 “docker rm” commands above. I haven’t run it personally yet.
Keep an eye on your disk usage. If you are experimenting heavily with Docker you could be running out quickly.
Thanks to my Cerner colleagues Jeff Kreutzer and Bobby Ryterski for discussing this issue and helping find resources.