Low Orbit Flux Logo 2 F

Docker no space left on device

Errors can be frustrating and this one has the potential to slow down your development cycle. It could even impact production if you failed to plan sufficiently. Depending on your situation it might be an easy fix or a huge messy operation. If you are reading this page there is a good chance you have come across the “Docker no space left on device” error. Hopefully this page will be helpful.

Docker no space left on device

Common Cause For “Docker no space left on device”

This error normally means that Docker does not have enough space. It stores its data here: /var/lib/docker. What ever file system that directory is mounted on will need to have enough free space.

NOTE - If you are running OSX things are a bit different, scroll down to the section on OSX for more details.

Basically these are your options:

Fix 1: Cleanup / Removing Containers

To fix this you can start out by removing unneeded containers, images, and volumes. This might be easy if you have a lot of junk left over that just needs to be cleaned up. This will be a lot harder if your storage is filled up with mostly useful data.

Fix 2: Expand Your Filesystem

You could also choose to expand your filesystem. This isn’t always possible but if you are using RAID or logical volumes it might be as easy as just adding a disk and growing the volume. It is a nice approach because it means you don’t have to move your data around. Depending on how your partitions are setup, you could theoretically resize your partitions but that is generally more effort than it is worth.

Fix 3: Add Another Disk and Mount Over Data Dir

WARNING - Make a backup before doing things. If you mistype a command or if my instructions contian a type you could destroy all of your data.

This is my favorite solution. You can add an extra disk and mount that over your docker directory. Before doing this you would copy the contents of the directory to the new disk. For example, lets say your new disk is /dev/sdb1:


sudo systemctl stop docker       # stop Docker

sudo mount /dev/sdb1 /mnt        # temp mount new disk
sudo mv /var/lib/docker/* /mnt/  # move data
sudo umount /mnt                 # unmount new disk

## setup a permanent mount point and mount it:
sudo echo "/dev/sdb1 /var/lib/docker ext4 defaults 0 0" >> /etc/fstab
sudo mount /var/lib/docker

sudo systemctl start docker      # start Docker

Storage Issues On OSX - Docker.qcow2

If you are running Docker on OSX you won’t be able to find /var/lib/docker. This is because Docker on OSX actually creates a VM and runs containers from within that. This VM uses a sparse disk image for storage. The /var/lib/docker dir is actually stored within this sparse disk image.

The disk image is located here:

~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2

If you don’t mind loosing existing containers and images you can just delete this file and restart Docker.

If you want to actually resize this disk image, there are instructions HERE and HERE.