I have an application inside a Docker container running Debian that has a feature that can import a lot of big files. The application stores the files in a folder on the host that is accessible via a bind mount from inside the container. This is a problem when a user points this import feature towards a set of files that is larger than the available storage, running out of space entirely makes the application very unhappy and I'd like to avoid that.

The problem is that it seems rather tricky to figure out the amount of free space on the correct partition from inside the container. I can execute df inside the container and get the free space on all partitions, but I don't know which partition is the correct one. The bind mount is always at the same path internal to the container, I can't find out which path outside the container this corresponds to.

Is there a way to figure out for a specific bind mounted folder inside a Docker container how much free space is available on the partition this folder is mounted from?

1 Answer 1


I believe you can use the format option of docker inspect to do what you are looking for:

MOUNTS=$(docker inspect -f '{{ range .Mounts }}{{ .Source }} {{ end }}' $CONTAINER_ID)

That will make a variable $MOUNTS with the locations all the bind mounts on $CONTAINER_ID are sourced from, separated by spaces.

Combine that output with df run from the host to determine how much space is available:

for source in $MOUNTS; do df -h $source; done

That should output the partitions all the mounts are sourced from and show the available space on those partitions.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .