Dealing with "No Space Left on Device" Errors in GitLab Runner

Modified on Tue, 24 Oct 2023 at 07:42 AM

Encountering "no space left on device" errors while running tasks on your GitLab Runner due to low disk space can be a frustrating roadblock. In this guide, we'll explore not only how to identify and address this issue but also provide additional steps specific to Docker-related space consumption, ensuring a smooth and efficient CI/CD pipeline.

If you're looking for a hassle-free solution, remember that Cloud-Runner offers managed GitLab runners, taking care of such issues for you.


Step 1: Check Disk Usage


Begin by assessing the disk utilization on the machine where the GitLab Runner operates. You can do this by running the following command:


df -h


This command will display the disk usage for all mounted file systems. Identify the file system that's running low on space.



Step 2: Clean Up Unused Files


If disk usage is excessive, it's time to declutter. Remove unused files, such as logs, transient files, and cached files, to free up space. You can locate and delete files older than a specified number of days using the find program. For instance, to delete files older than seven days, use:


find /path/to/files -type f -mtime +7 -exec rm {} \;


This command will clear out files older than a week in the specified path.



Step 3: Deal with Docker Space Consumption


Docker can often be a space hog, with its images, containers, volumes, and build cache. To keep Docker from monopolizing your disk space, implement regular pruning. Schedule the following commands as cron jobs (e.g., daily at midnight):


#Prune old images:
0 0 * * * docker image prune -a --filter "until=96h" -f
#Prune volumes:
0 0 * * * docker volume prune -f
#Prune containers older than 48 hours:
0 0 * * * docker container prune --filter "until=48h" -f
#Prune build cache:
0 0 * * * docker buildx prune --force


"No space left on device" errors can hamper your GitLab Runner's performance. By following the steps above, you can resolve these issues and ensure the smooth operation of your CI/CD pipeline.

However, if managing these tasks seems overwhelming, consider the convenience of Cloud-Runner's managed GitLab runners. Let us handle the complexities while you focus on your development goals. Explore Cloud-Runner today for an optimized CI/CD experience.


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article