Create amazing web applications!

How To Fix No Error Space Left On Device In Docker

Hello Pare, For today's tips and trick tutorial I'm going to show you how to fix No Error Space Left On Device when using docker.

by Anthony Pillos 3 minutes

tips-and-tricksdockerdocker-composeno-space-left-on-deviceerror

How To Fix No Error Space Left On Device In Docker

Hello Pare, For today's tips and trick tutorial I'm going to show you how to fix "No Error Space Left On Device" when using docker.

Sometimes you are wondering why we encounter this kind of error. You don't even touch anything in the server and then BOOM!!! 💣 💣 💣, when starting your docker container this will happen.

Error:

ERROR: Service failed to build: Error processing 🤬 🤬 🤬 /error : no space left on device

What is life pare

Take note the last part "No Space Left On Device". It only means that your server doesn't have enough space to store some files that were generating by your docker build.

To verify if you have still had enough space in your server you may try to run this command which displays your server available space.

df -h

Sample output:

Filesystem      Size  Used Avail Use% Mounted on
udev            487M     0  487M   0% /dev
tmpfs           100M   11M   89M  11% /run
/dev/vda1        25G   12G   13G  47% /
tmpfs           497M     0  497M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           497M     0  497M   0% /sys/fs/cgroup
/dev/vda15      105M  3.4M  102M   4% /boot/efi
Filesystem      Size  Used Avail Use%
/dev/vda1        25G   12G   13G  47%

Based on the output above, if you check the /dev/vda1, My server usage is almost 50%, which I only have 13G available storage. If somehow in your server Use% shown 99% or 100% then most probably the culprit of that is your docker unused containers, images and log files.

Question: ❓

How can we verify if our docker uses more storage in our server?

Answer: 👍

Using our disk usage command in linux. Type this command

sudo du -d1 -h /var/lib/docker | sort -hr

The output should be like this, which you may see the highest folder will be at the top of the lists. In my server, it was the /overlay2 folder.

15G	/var/lib/docker/overlay2
3G	/var/lib/docker
10M	/var/lib/docker/image
104K	/var/lib/docker/volumes
72K	/var/lib/docker/buildkit
60K	/var/lib/docker/network
48K	/var/lib/docker/containers
20K	/var/lib/docker/plugins
20K	/var/lib/docker/builder
4.0K	/var/lib/docker/trust
4.0K	/var/lib/docker/tmp
4.0K	/var/lib/docker/swarm
4.0K	/var/lib/docker/runtimes

SOLUTION:

Make sure to stop all running docker container before Run this command in your server.

docker image prune --all

or

docker image prune -a

This command will remove all unused images and all dangling images.

WARNING! This will remove all images without at least one container associated to them.
Are you sure you want to continue? [y/N] y
Deleted Images:
deleted: sha256:790970b04ff8e22cd270d0f7982171342d752bccdd1dc6f6766b1a7ac33b3bd0
deleted: sha256:c12f514bd279999f31026df9e5aed2dc754c35a7520e596890ec588bcc3a28c1
deleted: sha256:2b4a361fe45a666e43c801e096b7d00feb749018c43150d588af74231fd56242
deleted: sha256:82b34f1f1c88db1911fee1b6c30355d1cd11e5008340b7864e5ec72ca21038d8
deleted: sha256:f2547255f41064721a1e38ebf6b0ecb5c6465d0a2d28ea902a9a589b62c3e22f
deleted: sha256:508ff773b3ea98071360947fadf4c06dfd26bd31bdc77456ae887af3c30a20f7
...
deleted: sha256:7d033c77a944120fc9701264970a6216526039651fa71f29e5fc9949e27fe3d6

Total reclaimed space: 7.316GB

Double check again your storage space using df -h command, and check if you have enough space already.

df -h

After running the command you will reclaimed new storage space again. You may now start your docker or docker-compose up -d --build.

Voila

I hope we solve already your problem with regards to no space left on the device while using docker in your server. Let me know if you encounter a different problem and we will try to solve it together.

Thanks pare. 👊 👊 👊

Hooray

Next Featured

Do you want to learn how to make web apps using React? ✋ ✋ ✋ ✋

Just browse our latest tutorial in our react category section. Explore our list of tutorial for react js

Voila!!!

I hope you enjoy our tutorial, Let me know incase you encounter any error I would love to answer that. Don't forget to subscribe to my Youtube Channel at Let's Code Pare - Youtube Channel

Buy Me A Coffee

Share Now

Want to get more 🔥 tips like this one?

Subscribe to get notified for our new dev tutorials

Let's Code Pare
Let's Code Pare Youtube Channel