Query available space on disk in container (ASP.NET Core)

Hi!

Issue: different behavior in container
Image: mcr.microsoft.com/dotnet/core/aspnet:3.1

I’ve run into a strange error with my containerized ASP.NET Core microservice. I’m using DriveInfo and DirectoryInfo to get the available space in the given directory/drive. This works perfectly fine outside a container, but when I run the service containerized I’m getting 0 bytes available.
The folders in question are mounted in docker compose. I’ve tried to replace them with volumes but I got the same error. I’m getting the exact same error when I don’t mount anything at all.
Running the image with shell I can get the proper values with “df -h”.
I would like to keep my code multiplatform and clean so I would rather not resort to Windows or Linux specific solutions.

Can you please provide some insight into why this is happening? In the event that what I’m doing is incorrect, can you please point me in the right direction regarding how I can check available disk space on my drive from inside my docker container?

Thank you!