How to fix the “no space left on device” error when building Docker images

Peter Jausovec
2 min readDec 23, 2022

If you are getting a “no space left on device” error when trying to build a Docker image, it could be because the system running the Docker daemon has run out of available disk space. You can use the dfcommand to check the available disk space on your system.

For example:

$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 7.4G 0 7.4G 0% /dev
tmpfs 1.5G 8.5M 1.5G 1% /run
/dev/sda1 99G 62G 33G 66% /
tmpfs 7.4G 0 7.4G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 7.4G 0 7.4G 0% /sys/fs/cgroup
/dev/sda15 124M 5.9M 118M 5% /boot/efi
/dev/sdb 98G 22G 77G 23% /home/jupyter

Based on the output, you can figure out how close to running out of disk space you are and delete the unwanted files.

You can also use the find command to locate large files. This command shows all files that are larger than 500 MB:

find . -xdev -type f -size +500M

You should also remove unused Docker images and containers using the docker system prune command.

Another option (if it is an option) is to increase the disk size used by the Docker daemon. If you are using a virtual machine, you may be able to increase the disk size or attach an additional one.

Mounting a separate volume with more disk space to the Docker daemon’s data directory can also help. You can do this by using the -v flag when starting the Docker daemon.

--

--