Actions for warning “Your Jenkins data directory /var/lib/jenkins is almost full”

When I was encountering this problem, I could not build the job. Jenkins shown this warning message Your Jenkins data directory /var/lib/jenkins (AKA JENKINS_HOME) is almost full. You should act on it before it gets completely full.

I checked the disk space and here it shows:

admin@thachhoang:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev             16G     0   16G   0% /dev
tmpfs           3.2G  1.7M  3.2G   1% /run
/dev/sda2       197G   197G   0G 100% /
tmpfs            16G   20K   16G   1% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs            16G     0   16G   0% /sys/fs/cgroup
/dev/loop0       92M   92M     0 100% /snap/core/8689

I found out the reason is that there are a lot of dangling images generated with ID and tag <none> which caused disk space problems.

These dangling images are produced as a result of docker build or pull command. more detail explanation here

admin@thachhoang:~$ sudo docker image ls
REPOSITORY                                          TAG                 IMAGE ID            CREATED             SIZE
frontend                                            latest              f4ff7e585249        3 hours ago         74.5MB
<none>                                              <none>              df960ce8afd8        3 hours ago         74.5MB
<none>                                              <none>              8ffb0de2aef9        5 hours ago         2.69GB
<none>                                              <none>              5aef9689ebb3        5 hours ago         2.53GB
<none>                                              <none>              90c914fcaaf0        7 hours ago         74.5MB
backend-payment                                     latest              2403e4ca333d        12 hours ago        310MB
<none>                                              <none>              ad6fc261739a        33 hours ago        319MB
<none>                                              <none>              2d00312d4e71        33 hours ago        1.75GB
<none>                                              <none>              44ffe53cc491        41 hours ago        2.28GB
<none>                                              <none>              edf28e9d9edf        42 hours ago        2.58GB
<none>                                              <none>              058e82ceb897        42 hours ago        2.57GB
<none>                                              <none>              9abf902cc5a1        2 days ago          1.75GB
<none>                                              <none>              637639ef34b2        2 days ago          2.28GB

The below command can be used to clean up these dangling images:

docker rmi $(docker images -f "dangling=true" -q).

Or use this one if you see any permission denied.

sudo docker rmi $(sudo docker images -f "dangling=true" -q)

In addition, you should enable “Discard old builds” option in all Jenkins Jobs configuration to save the space.

Leave a comment