Why is /var/lib/docker so large?

Vincent Jul 15, 2026

The /var/lib/docker directory, a fundamental component of the Docker ecosystem, often raises an issue among users due to its significant size and growth. This article delves into the reasons behind this phenomenon, helping you understand and manage your Docker environment more effectively.

Setting up Vaultwarden using Docker
Setting up Vaultwarden using Docker

The /var/lib/docker folder is where Docker stores various components, including images, containers, and the graph database that keeps track of dependencies between objects. The size of this directory can grow substantially over time, leading to the question: why is var lib docker so large?

the diagram shows how to use docker
the diagram shows how to use docker

The Docker Image Layering System

The Docker image layering system is a major contributing factor to the size of the /var/lib/docker directory. Each image is composed of layers, and changes between images are stored as new layers. This allows for efficient storage and distribution of images, as only the differences between images need to be stored.

Docker and how it works
Docker and how it works

However, while this system minimizes the space required to store new images, it can result in a large number of layers being stored in the /var/lib/docker directory. Over time, these layers can accumulate and contribute significantly to the overall size of the directory.

Docker Image Size Growth

Javascript
Javascript

Docker images themselves can grow in size over time. Images pulled from registry might include updates, new packages, or additional tools, which increase the image size. Furthermore, images can inherit or include large base images, further contributing to their size and the overall size of the /var/lib/docker directory.

To illustrate, let's say you have an image with a base image that's 100MB. If you add 50MB of your own changes, the total size of the image stored in the /var/lib/docker directory is now 150MB - even if you've only added 50MB to the image itself.

Docker Containers and Data Persistence

Kubernetes vs Docker: What is the Difference?
Kubernetes vs Docker: What is the Difference?

Docker containers also contribute to the size of the /var/lib/docker directory. Changes made within a container are not reflected in the original image. Instead, they are stored in a new writeable layer. This means that every time you make a change in a container, you're essentially adding a new layer to your disk.

Moreover, if you're using data volumes or bind mounts, the data stored in those volumes is also saved in the /var/lib/docker directory. Over time, these data can accumulate and occupy significant space, further growing the size of the /var/lib/docker directory.

Container and Image Pruning

Difference Between Kubernetes and Docker
Difference Between Kubernetes and Docker

To manage the size of the /var/lib/docker directory, Docker provides built-in functions for removing unused objects. Containers and images that are not in use can safely be removed to free up space.

However, it's crucial to understand that these operations are not destructive and only remove objects that are not in use. They do not delete running containers or images that are being used by running containers. Also, they don't remove data stored in volumes, as this data might still be in use.

Tail the Logs of your Docker Containers
Tail the Logs of your Docker Containers
Sharing Your Docker Images: A Step-by-Step Guide 🚀
Sharing Your Docker Images: A Step-by-Step Guide 🚀
Ȼłⱥᵴᵴîȼⱥł “Ʀⱥɉøᵰ”
Ȼłⱥᵴᵴîȼⱥł “Ʀⱥɉøᵰ”
Docker Introduction | Docker Architecture and Working | What is Docker?
Docker Introduction | Docker Architecture and Working | What is Docker?
Running qBittorrent using Docker
Running qBittorrent using Docker
Stop Using Outdated Docker Images - How I Used WUD to Track Container Updates - Make Tech Easier
Stop Using Outdated Docker Images - How I Used WUD to Track Container Updates - Make Tech Easier
How to Use a Dockerfile to Build a Docker Image
How to Use a Dockerfile to Build a Docker Image
a man sitting on the back of a truck next to a green grass covered field
a man sitting on the back of a truck next to a green grass covered field
How to Install and Use Docker in Your Linux System
How to Install and Use Docker in Your Linux System
Docker on OpenBSD 6.1 (-current)
Docker on OpenBSD 6.1 (-current)
Setting up the Deluge Torrent Client with Docker
Setting up the Deluge Torrent Client with Docker
Setup your own GitLab with Docker
Setup your own GitLab with Docker
Install Docker on Windows 11: Step-by-Step Guide for a Fresh WSL 2 Setup
Install Docker on Windows 11: Step-by-Step Guide for a Fresh WSL 2 Setup
Live Reloading With Docker Compose for Efficient Development
Live Reloading With Docker Compose for Efficient Development
Self-host Gitlab using Docker
Self-host Gitlab using Docker
a computer screen with the words logical not 1
a computer screen with the words logical not 1
Emotional Stories, Inspiring Stories, Lotr Funny Moments, Humorous Star Wars Moments, Lord Of The Rings Funny Moments, Heartwarming Family Stories, Kind Stories, Harry Potter Saddest Moments, Out Of Context Harry Potter Quotes
Emotional Stories, Inspiring Stories, Lotr Funny Moments, Humorous Star Wars Moments, Lord Of The Rings Funny Moments, Heartwarming Family Stories, Kind Stories, Harry Potter Saddest Moments, Out Of Context Harry Potter Quotes
先進的な Linux デスクトップ | The Fedora Project
先進的な Linux デスクトップ | The Fedora Project
Docker Volumes Explained with Spring Boot & PostgreSQL Application [ DevOps ]
Docker Volumes Explained with Spring Boot & PostgreSQL Application [ DevOps ]
Disorders list | Disorder chart, Common mental disorders, Adhd quiz
Disorders list | Disorder chart, Common mental disorders, Adhd quiz

Automatic Pruning

Docker has a built-in mechanism for automatically pruning containers and images. You can configure this by creating a JSONObject file in /etc/docker/daemon.json to specify the filters for pruning. For example:

{"dangling": true, "prune": true}

This configuration will remove all unused containers, images, networks, and volumes, as well as any dangling (unused) objects.

Manual Pruning

Alternatively, you can manually remove unused objects using the Docker command-line interface (CLI). The following commands can help you manage your Docker objects:

  • docker ps -a -q --filter status=dead --filter status=exited | xargs docker rm
  • docker image prune
  • docker container prune
  • docker system prune

The first command removes all stopped containers, while the others remove unused images, unused containers, and unused objects, respectively.

While /var/lib/docker's size can be an issue, understanding and managing its growth makes it a manageable part of your Docker experience. Regularly cleaning up unused objects and monitoring your image usage can help keep the /var/lib/docker directory at a reasonable size, freeing up valuable disk space on your system.