Check Available Disk Space with Remote Docker and Docker Layer Caching

Recommended commands 

When running Remote Docker with Docker Layer Caching you can run the following commands to see how much space has been currently used on the volume before running your build.

ssh remote-docker 'sudo df' | grep '/var/lib/docker' | awk '{print $4}'

You could store that value and use it to see how much remaining space you have. Our DLC volumes are 50GB.

DLC_AVAILABLE_SPACE=$(ssh remote-docker 'sudo df' | grep '/var/lib/docker' | awk '{print $4}');


Additional options

You could also simply run the following command to output the available space into your build logs

docker system df