Skip to main content

How to Check Disk Space Usage for Docker Images, Containers and Volumes

A collection of tips to let you know how to check disk space usage of Docker Images, Containers and Volumes on your Linux server host.

Warp Terminal

Wondering how much space does Docker consume on your Linux system?

Primarily, all Docker images, containers and other related entities are located at /var/lib/docker. You can check the size of this directory and get the total disk space used by Docker:

avimanyu@iborg-desktop:~$ sudo du -sh /var/lib/docker
4.9G	/var/lib/docker

But that's not very descriptive and you may have to go further in this directory to see which component uses what space.

Thankfully, Docker has provided tools to get this information in more useful way.

Checking Docker disk space usage [The Docker Way]

The most basic, "Docker" way to know how much space is being used up by images, containers, local volumes or build cache is:

docker system df

When you run this command (use sudo if necessary), you get all disk usage information grouped by Docker components.

root@ghost-lhb:/var/lib# docker system df
TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          22        6         9.675GB   8.22GB (84%)
Containers      7         4         17.13MB   17.13MB (99%)
Local Volumes   6         6         315kB     0B (0%)
Build Cache     13        0         3.158kB   3.158kB

This is definitely better than looking at the total size of /var/lib/docker. You can see how much space is consumed by images, containers and volumes.

However, this still does not provide a clear picture on which image or volume takes more space.

Actually, it does. The docker system df command has the verbose option -v that gives all these details.

docker system df -v

Here's the verbose output:

root@ghost-lhb:/var/lib# docker system df -v
Images space usage:

REPOSITORY              TAG        IMAGE ID       CREATED         SIZE      SHARED SIZE   UNIQUE SIZE   CONTAINERS
<none>                  <none>     b1583dcfc81e   18 hours ago    207MB     162.2MB       44.78MB       1
ghost                   6-alpine   9618151b9ed4   37 hours ago    744MB     162.2MB       581.4MB       2
<none>                  <none>     a46eec249231   7 days ago      743MB     162.2MB       580.7MB       0
<none>                  <none>     023c6eab57f4   9 days ago      207MB     162.2MB       44.75MB       0
<none>                  <none>     5500aaeb84f6   9 days ago      207MB     162.2MB       44.74MB       0
<none>                  <none>     08c68d279ffa   12 days ago     743MB     162.2MB       580.7MB       0
<none>                  <none>     3fac6fb0e63e   4 weeks ago     198MB     162.2MB       35.97MB       0
<none>                  <none>     f321510e4d3e   4 weeks ago     741MB     162.2MB       578.6MB       0
<none>                  <none>     5d08b8b96f21   2 months ago    740MB     162.2MB       578MB         0
<none>                  <none>     29a8fe8a6013   2 months ago    198MB     162.2MB       35.58MB       0
<none>                  <none>     927d2272cc9a   2 months ago    738MB     162.2MB       575.4MB       0
<none>                  <none>     ccca2440a7ea   3 months ago    713MB     8.322MB       704.4MB       0
<none>                  <none>     d778cb4d0eb7   3 months ago    713MB     162MB         550.9MB       0
<none>                  <none>     8516fa629c6a   3 months ago    198MB     162MB         35.58MB       0
<none>                  <none>     34178dbaefd0   4 months ago    783MB     0B            783.3MB       1
ghost-tinybird-deploy   latest     2b00541fcdb7   5 months ago    488MB     488.3MB       0B            1
ghost-tinybird-login    latest     efe54480d3e3   5 months ago    488MB     488.3MB       0B            1
<none>                  <none>     e4bd530ab75a   5 months ago    53.5MB    8.322MB       45.14MB       1
<none>                  <none>     f278ad347269   5 months ago    675MB     159.5MB       515.3MB       0
<none>                  <none>     88a0921423a1   6 months ago    1.4GB     159.5MB       1.241GB       0
<none>                  <none>     14300de7e087   10 months ago   50.5MB    0B            50.53MB       0
<none>                  <none>     84914bb1b365   10 months ago   772MB     0B            771.8MB       0

Containers space usage:

CONTAINER ID   IMAGE                            COMMAND                   LOCAL VOLUMES   SIZE      CREATED          STATUS                      NAMES
99001bd06371   ghost:6-alpine                   "docker-entrypoint.s…"    0               0B        10 minutes ago   Up 10 minutes               ghost-ghost-1
bc66787decd6   mysql:8.0.44                     "docker-entrypoint.s…"    0               6B        10 minutes ago   Up 10 minutes (healthy)     ghost-db-1
562e2daf0643   ghost/traffic-analytics:1.0.85   "docker-entrypoint.s…"    1               0B        31 minutes ago   Up 28 minutes               ghost-traffic-analytics-1
6b20f4674182   ghost:6-alpine                   "docker-entrypoint.s…"    2               0B        31 minutes ago   Exited (0) 10 minutes ago   ghost-tinybird-sync-1
41bb974b9804   caddy:2.10.2-alpine              "caddy run --config …"    2               0B        3 weeks ago      Up 28 minutes               ghost-caddy-1
7bfa64fc44b1   ghost-tinybird-deploy            "sh -c '\n  tb-wrappe…"   2               17.1MB    5 months ago     Exited (0) 10 minutes ago   ghost-tinybird-deploy-1
94dab4243e12   ghost-tinybird-login             "/usr/local/bin/tiny…"    2               0B        5 months ago     Exited (0) 10 minutes ago   ghost-tinybird-login-1

Local Volumes space usage:

VOLUME NAME                                                        LINKS     SIZE
ghost_traffic_analytics_data                                       1         192B
851018e40a8def0465cd97ded10eab524715301fa2b89ee7859ce15cb0e98ada   1         0B
ghost_caddy_config                                                 1         2.362kB
ghost_caddy_data                                                   1         8.248kB
ghost_tinybird_files                                               3         303.2kB
ghost_tinybird_home                                                2         964B

Build cache usage: 3.158kB

CACHE ID       CACHE TYPE     SIZE      CREATED        LAST USED      USAGE     SHARED
hf9c9f0rf6ap   regular        0B        5 months ago   5 months ago   1         true
obj28ycvngz1   regular        0B        5 months ago   5 months ago   1         true
augazok6r4ik   regular        0B        5 months ago   5 months ago   1         true
1aqkdbck8vkd   regular        7.39MB    5 months ago   5 months ago   1         true
7ycy4oveqbgn   regular        1.15kB    5 months ago   5 months ago   1         true
myz08owjyqbe   regular        473B      5 months ago   5 months ago   1         true
svwdxxkyy3co   regular        0B        5 months ago   5 months ago   1         true
trlj4l32xw8a   regular        0B        5 months ago   5 months ago   1         true
okoawnrct855   regular        982B      5 months ago   5 months ago   1         true
j8mts8f8n57c   source.local   0B        5 months ago   5 months ago   2         false
dmo2mxgytu42   source.local   2.61kB    5 months ago   5 months ago   2         false
co7uf239zsiq   regular        360MB     5 months ago   5 months ago   2         true
wdjc8nyjkhbu   source.local   551B      5 months ago   5 months ago   2         false

That's nice, right? There are other ways too.

Checking docker image sizes

If you just want to see the Docker images and their sizes, you may also use this command:

docker image ls

It lists all the Docker images on your system with a few details that include the size:

avimanyu@iborg-desktop:~$ docker image ls
REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
busybox       latest    beae173ccac6   6 weeks ago     1.24MB
ubuntu        latest    fb52e22af1b0   5 months ago    72.8MB
alpine        latest    49f356fa4513   10 months ago   5.61MB
hello-world   latest    d1165f221234   11 months ago   13.3kB

Checking running container sizes

Similarly, if you want to know the size of running Docker containers, you can use the docker ps command:

docker ps --size

You should see a SIZE column added to the output of the command:

avimanyu@iborg-desktop:~$ docker ps --size
CONTAINER ID   IMAGE     COMMAND      CREATED         STATUS         PORTS     NAMES           SIZE
1171dcfb7e06   alpine    "sleep 10"   10 months ago   Up 9 seconds             always-policy   0B (virtual 5.61MB)

Do you notice how it says 0B and then shows a virtual 5.61 MB? The virtual size includes the shared underlying image.

Let us go back to the Linux approach into it more specifically, with the Alpine image and container as a hands-on example.

Using standard Linux commands to analyze Docker disk space usage

Whenever you use the docker pull command or run docker-compose up -d to prepare the launch of applications, this is how you look for image space usage, actually stored on an Ubuntu 20.04 server:

sudo du -sh /var/lib/docker/overlay2/<hash-named-directory>/

Here, Overlay2 is the default Docker storage driver on Ubuntu. You can confirm this by running the docker info command and looking for the Storage Driver:

Storage Driver: overlay2

If this is different than yours, then you're using a different storage driver for Docker. Likewise, the directory location would be named as per the same storage driver. Availability of the storage driver depends upon kernel support.

Specific Image Disk Usage

If you are looking for the locations of specific images, you can use the Docker inspect command for the pulled image. Say, for example, I've pulled the alpine image with docker pull alpine. Run the following command to inspect it:

$ docker inspect alpine

Once you run the command, you'll notice three fields inside the Data subsection under GraphDriver:

...
        "GraphDriver": {
            "Data": {
                "MergedDir": "/var/lib/docker/overlay2/64c9c0cf8c9cfb0e2168071df0652a317d49f58a68fe86e4a9a9a525ab9e365e/merged",
                "UpperDir": "/var/lib/docker/overlay2/64c9c0cf8c9cfb0e2168071df0652a317d49f58a68fe86e4a9a9a525ab9e365e/diff",
                "WorkDir": "/var/lib/docker/overlay2/64c9c0cf8c9cfb0e2168071df0652a317d49f58a68fe86e4a9a9a525ab9e365e/work"
            },

...

Based on the above information, you can see that the (mentioned earlier in the du command syntax) in this case is 64c9c0cf8c9cfb0e2168071df0652a317d49f58a68fe86e4a9a9a525ab9e365e.

Here, you can run the following command to reveal the amount of space being used by the Alpine image:

avimanyu@iborg-desktop:~$ sudo du -sh /var/lib/docker/overlay2/64c9c0cf8c9cfb0e2168071df0652a317d49f58a68fe86e4a9a9a525ab9e365e
6.0M	/var/lib/docker/overlay2/64c9c0cf8c9cfb0e2168071df0652a317d49f58a68fe86e4a9a9a525ab9e365e

Similarly, like images, containers are also stored inside the same storage driver based directory.

/var/lib/docker/overlay2

Specific Container Disk Usage

If you are looking for the locations of specific containers, you can again use the inspect command on Docker for the running container. Say, for example, I've run the alpine container with docker run -ti -d alpine . When you run docker ps, you'll see that it's running:

$ docker ps
CONTAINER ID   IMAGE     COMMAND     CREATED         STATUS         PORTS     NAMES
cb341d6a28fa   alpine    "/bin/sh"   6 seconds ago   Up 5 seconds             confident_banzai

Here, the container has been randomly named confident_banzai. So let's inspect it:

$ docker inspect confident_banzai

Once you run the above command, you'll notice all the four fields mentioned earlier inside the Data subsection under GraphDriver. These locations are where the container data is physically stored on your host system just as you saw for images:

...
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/d734685e284c92bdcb6063ac292a48813f30f4b0b2dd6fa2882279c569e506a3-init/diff:/var/lib/docker/overlay2/64c9c0cf8c9cfb0e2168071df0652a317d49f58a68fe86e4a9a9a525ab9e365e/diff",
                "MergedDir": "/var/lib/docker/overlay2/d734685e284c92bdcb6063ac292a48813f30f4b0b2dd6fa2882279c569e506a3/merged",
                "UpperDir": "/var/lib/docker/overlay2/d734685e284c92bdcb6063ac292a48813f30f4b0b2dd6fa2882279c569e506a3/diff",
                "WorkDir": "/var/lib/docker/overlay2/d734685e284c92bdcb6063ac292a48813f30f4b0b2dd6fa2882279c569e506a3/work"
            },
            "Name": "overlay2"
        },
...

Now you can use the du command again:

avimanyu@iborg-desktop:~$ sudo du -sh /var/lib/docker/overlay2/d734685e284c92bdcb6063ac292a48813f30f4b0b2dd6fa2882279c569e506a3
32K	/var/lib/docker/overlay2/d734685e284c92bdcb6063ac292a48813f30f4b0b2dd6fa2882279c569e506a3

Unlike Docker images and containers, the physical locations for volumes is pretty straightforward. Volumes are located at:

/var/lib/docker/volumes/

Therefore, you can run the following command to know the entire Docker volume disk space usage on your system:

avimanyu @iborg-desktop:~$ sudo du -sh /var/lib/docker/volumes/
60K	/var/lib/docker/volumes/

Specific Volume Disk Usage

In this case, there are two types primarily. One is regular Docker volumes and the other is bind mounts.

Docker Volumes

If you are looking for the locations of specific volumes, you can use the docker volume ls command first and check the volume name or ID. Say, for example, I've run the alpine container with the following command with a volume:

docker run -ti -d --name alpine-container -v test-data:/var/lib/app/content alpine

Now, a volume named test-data will automatically get created. Let's now create a file named test.md inside this location:

$ docker exec alpine-container sh -c "touch /var/lib/app/content/test.md"

Verify the file has indeed been created:

$ docker exec -ti alpine-container sh
/ # ls /var/lib/app/content/
test.md
/ # exit

When you run docker volume ls, the volume named test-data would be listed:

$ docker volume ls
DRIVER    VOLUME NAME
local     d502589845f7ae7775474bc01d8295d9492a6c26db2ee2c941c27f3cac4449d1
local     e71ee3960cfef0a133d323d146a1382f3e25856480a727c037b5c81b5022cb1b
local     test-data

Finally, you can confirm the actual location of the file on your host system:

$ sudo ls -l /var/lib/docker/volumes/test-data/_data
total 0
-rw-r--r-- 1 root root 0 Oct  6 23:20 test.md

Therefore, the path for the mounted volume is always located inside a directory named _data inside the respective volume directory.

So, you can use the du command here again for specific volumes!:

avimanyu@iborg-desktop:~$ sudo du -sh /var/lib/docker/volumes/test-data/_data
4.0K	/var/lib/docker/volumes/test-data/_data

Always remember to note the volume name every time you want to find out how much space your volume is using.

Bind Mounts

This is the only exception in Docker where you have to use a Linux approach to monitor disk space usage. At the same time, it is always preferable to stop the running containers first.

$ mkdir /home/avimanyu/test-data
$ docker run -ti -d --name alpine-container -v /home/avimanyu/test-data:/var/lib/app/content alpine

In this case, a bind mounted volume named test-data will become available on the container side as /var/lib/app/content.

avimanyu@iborg-desktop:~$ sudo du -sh /home/avimanyu/test-data
4.0K	/home/avimanyu/test-data

You can also test the same thing inside the container:

avimanyu@iborg-desktop:~$ sudo docker exec -ti alpine-container sh
/ # du -sh /var/lib/app/content
4.0K	/var/lib/app/content

As you can see, both the sizes reported above are the same because they are actually bind mounts.

Docker logs on the host are always stored in volumes. Using the described way in this section, users can also navigate and find that out by looking at docker volumes disk space usage. This varies from app to app and the location of log files in the app volumes.

Bonus Tips

Based on what you learned till now, very obviously, you can also use the following command to fetch the disk usage of images and containers together:

sudo du -sh /var/lib/docker/overlay2

Docker logs on the host are always stored in volumes. A usually large Docker volume would most likely indicate that logs have been piling up and are being managed inefficiently.

How to Check Docker Logs [Stored or Real Time]
Explore and learn some interesting ways to make log management easier on Docker.

Using the described way in the volumes' section of this article, users can also navigate and mitigate this by looking at docker volumes disk space usage. This varies from app to app and the location of log files in the app volumes.

Summary

In this tutorial, I've taken a generic Linux based approach to show you how to find out disk space occupancy of Docker images, containers and volumes residing on your Linux server at the host level. You also learned how to do it the preferred (Docker) way.

If you want to share any feedback, comment or suggestion towards this approach, please leave your thoughts in the comment section below

Updated on Feb 18, 2026

About the author

Avimanyu Bandyopadhyay Avimanyu Bandyopadhyay