I installed docker on a Debian 7 machine in the following way
$ echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list
$
If you're using the boot2docker image via Docker Toolkit, then the problem stems from the fact that the boot2docker virtual machine has run out of space.
When you do a docker import
or add a new image, the image gets copied into the /mnt/sda1
which might have become full.
One way to check what space you have available in the image, is to ssh into the vm and run df -h
and check the remaining space in /mnt/sda1
The ssh command is
docker-machine ssh default
Once you are sure that it is indeed a space issue, you can either clean up according to the instructions in some of the answers on this question, or you may choose to resize the boot2docker image itself, by increasing the space on /mnt/sda1
You can follow the instructions here to do the resizing of the image https://gist.github.com/joost/a7cfa7b741d9d39c1307
to remove all unused containers, volumes, networks and images at once (https://docs.docker.com/engine/reference/commandline/system_prune/#related-commands):
docker system prune -a -f --volumes
if it's not enough, one can remove running containers first:
docker rm -f $(docker ps -a -q)
docker system prune -a -f --volumes
increasing /var/lib/docker or using another location with more space is also a good alternative to get rid of this error (see How to change the docker image installation directory?)
If you're using Docker Desktop, you can increase Disk image size in Advanced Settings by going to Docker's Preferences.
Here is the screenshot from macOS:
The current best practice is
docker system prune
This will remove:
- all stopped containers
- all volumes not used by at least one container
- all networks not used by at least one container
- all dangling images
This is permanent.
Make sure you read this answer, re: Volumes
You may also be interested in this answer, if docker system prune
does not work for you.
So docker system prune
and docker system prune --volumes
suggested in other answers freed up some space each time, but eventually every time I ran anything I was getting the error.
What actually fixed the root issue was deleting the Docker.raw
file that Docker for Mac uses for storage, and restarting it.
To find that file open up Docker for Mac and go to*
Preferences > Resources > Advanced > Disk Image Location
*this is for version 2.2.0.5, but on older versions it should be similar
On newer versions of Docker for Mac**, it shows you the actual size of that file on disk right there in the UI, as well as its max allocated size. You'll probably see that it is massive. For example on my machine it was 41GB!
**On older versions, it doesn't show you the actual disk usage in the UI, and MacOS Finder always shows the file size as the max allocated size. You can check the actual size on disk by opening the directory in a terminal and running
du -h Docker.raw
I deleted Docker.raw
, restarted Docker for Mac, and the file was automatically created again and was back to being 0GB.
Everything continued to work as before, though of course I had lost my Docker cache. As expected, after running a few Docker commands the file started to fill up again with a few GB of stuff, but nowhere near 41GB.
Update
A few months later, my Docker.raw
filled back up again to a similar size. So this method did work, but has to repeated every few months. For me that's fine.
A note on why this works - I have to assume it's a bug in Docker for Mac. It really seems like docker system prune
/ docker system prune --volumes
should entirely clear the contents of this file, but it appears the file accumulates other stuff that can't be deleted by these commands. Anyway, deleting it manually solves the problem!
Clean Docker by using the following command:
docker images --no-trunc | grep '<none>' | awk '{ print $3 }' \
| xargs docker rmi