How to check disk usage of the CONTAINER ID on Ubuntu?

To check disk usage of the Docker container with ID e9a21548ff1c on Ubuntu, you have several options:

Method 1: Check from inside the container

docker exec e9a21548ff1c df -h

This shows disk usage of filesystems mounted inside the container.

Method 2: Check container’s writable layer size

docker system df -v

This shows detailed disk usage for all containers, including your specific container.

Method 3: Inspect container filesystem from host

sudo du -sh /var/lib/docker/containers/e9a21548ff1c*

This shows the size of the container’s writable layer on the host filesystem.

Method 4: Real-time container stats

docker stats e9a21548ff1c --no-stream

This shows CPU, memory, network, and block I/O usage (though not total disk usage).

Method 5: Check specific directories inside container

docker exec e9a21548ff1c du -sh /path/to/directory

Replace /path/to/directory with the specific path you want to check.

Method 6: Get detailed container information

docker inspect e9a21548ff1c | grep -i size

Most commonly used: Method 1 (docker exec e9a21548ff1c df -h) gives you a quick overview of disk usage from the container’s perspective, while Method 2 (docker system df -v) shows how much space the container is using on your host system.

Leave a Reply