Select Page

How to clear Docker cache and save disk space

How to clear Docker cache and save disk space

You can spin up a Docker container in a few seconds. A quick “docker run” command, and voila, your shiny new app is online. But this simplicity often leads to a performance bottleneck – High Disk Space usage.

Docker focuses on fast container deployment, and doesn’t focus much on disk space management. That’s why manual intervention is required to manage disk space in Docker machines.


A Docker machine can host multiple containers, each created with an image. The Docker images are downloaded and created using the instructions provided in a Dockerfile.

If not managed properly, these images can take up your disk space and crash the server. In our Docker Management Services, we help online businesses ensure high service uptime and performance.

Running out of disk space in Docker?



Today, we’ll take a look at how Docker cache buildup can be prevented, and cleaned up regularly.

What is Docker cache?

Whenever a container is created for the first time, its corresponding Dockerfile is also executed for the first time. This creates a new Docker image, which is stored in the folder ‘/var/lib/docker’ by default.

During further runs of Dockerfile, Docker will create and commit a new layer to the already existing image. These images are stored in the cache.

Unless explicitly instructed, Docker always looks for an existing image in its cache, whenever a new container is created. Reusing images from the cache helps to speed up the container deployment process in Docker.

Is Docker cache problematic?

While Docker cache helps speed up container creation process, there are certain situations where using the Docker cache will fail the purpose.

For instance, in the case of a source code checkout, we need the latest code to be available. In such cases, we can specifically give instructions not to use the cache.

This is referred to as busting the cache. The Dockerfile command in such cases would look like ‘docker build –no-cache=true’.

Another major concern is that the Docker images in the cache take up disk space. The size of a Docker image is the total space taken up by the image and all its parent images.

In the long run, you will find your Docker machine running out of disk space, as a result of all the Docker images here and there. So, its important to clear the cache regularly.

[ Are your containers crying over space constraints? Our Docker experts take care of your infrastructure and ensure adequate space for smooth functioning. ]

Looking for a stable Docker setup?

Talk to our Docker specialists today to know how we can keep your containers top notch!


Submit a Comment

Your email address will not be published. Required fields are marked *

Bobcares is a server management company that helps businesses deliver uninterrupted and secure online services. Our engineers manage close to 51,500 servers that include virtualized servers, cloud infrastructure, physical server clusters, and more.

Privacy Preference Center


Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]


Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid


Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie

Close your account?

Your account will be closed and all data will be permanently deleted and cannot be recovered. Are you sure?