MacOS Docker Bind Mount reports incorrect free space

Hi, I don’t use docker often, but I’m hosting a samba share with it on my mac Mini and I ran into an issue of df reporting the wrong free space for my bind mount. It reports 36.5GB free instead of 7.2TB.
This was the command I used:

docker run -p 445:445 -v “/Volumes/eVault/ROM Database/Sony/PS2”:/mnt/ps2games -v “/Volumes/eVault”:/mnt/eVault servercontainers/samba

Any help is appreciated thank you.

1 Like

Are you sure your disk was properly mounted and the free space is not the free space on your Mac or in the virtual machine of Docker Desktop?

I’ve been hitting this issue for quite some time now. In my situation, there are two things that may be relevant (not sure if either of these apply to @hunterahlquist

  • I tried mounting a folder from a Seagate 4TB external (USB) drive. The drive has 1TB free, but df -H reports only 29G free
  • I tried mounting a folder from a JBOD disk array (8TB across 3 drives). This drive has 4.5TB free, but df -H reports only 29G free
    It’s interesting to me that the reported free space is the same, despite the two being completely unique drives. I wouldn’t be surprised if the JBOD setup is not officially supported, which is why I tried the other (more basic) scenario.

When you run a container and check the mounted folders you will see the disk mounted into the container and the size of it in the list of mounted disks.

Docker Desktop on macOS can’t just mount the folders from the host directly into containers. There is a virtual machine and one more layer of containers (containerd) between the host and a Docker container so it has to do some magic to mount the folder to the virtual machine, then into the containerd container and from that you mount into a Docker container so it seems it will show you the size of the main disk of the Mac host where the /Volumes folder is.

For example when I list the disks on my Mac host, this is what I see

/dev/disk3s1s1   460Gi   9.2Gi   159Gi     6%    390k  1.7G    0%   /
/dev/disk4s1     1.8Ti   896Gi   967Gi    49%       1     0  100%   /Volumes/ta-exfat-2t

When I run a container and execute df in that,

docker run --rm -v /Volumes/ta-exfat-2t/Movies/files:/files ubuntu df -

this is what I see

/host_mark/Volumes      460.4G    301.7G    158.7G  66% /files

host_mark comes from the containerd container, because this is how the folder is mounted from the virtual host which you can check this way:

docker run --rm --privileged --pid host ubuntu nsenter --all -t 1 \
  -- ctr -n services.linuxkit task exec --exec-id test 02-docker \
     df -h | grep host_mark
/host_mark/Users        461G  302G  159G  66% /host_mnt/Users
/host_mark/Volumes      461G  302G  159G  66% /host_mnt/Volumes
/host_mark/private      461G  302G  159G  66% /host_mnt/private
/host_mark/tmp          461G  302G  159G  66% /host_mnt/tmp
/host_mark/var/folders  461G  302G  159G  66% /host_mnt/var/folders

Then

docker run --rm --privileged --pid host ubuntu nsenter --all -t 1 \
  -- ctr -n services.linuxkit task exec --exec-id test 02-docker \
     ls -la /host_mnt
total 0
drwxr-xr-x  7 root root  140 Nov 18 21:02 .
drwxr-xr-x  1 root root 1440 Nov 18 21:02 ..
drwxr-xr-x  5 root root  160 Nov  1 22:50 Users
drwxr-xr-x  4 root root  128 Nov 19 13:51 Volumes
drwxr-xr-x  6 root root  192 Nov 16 20:32 private
drwxrwxrwt 21 root root  672 Nov 19 11:58 tmp
drwxr-xr-x  3 root root   60 Nov 18 21:02 var

Your docker commands will be converted to mount the folders properly from the containerd container (currently) called “02-docker”, but when you run docker container inspect you will still see the host folder because the response will be converted too. You can check it this way if you have “jq” installed on Mac:

## in my case:
# docker run -d -v /Volumes/ta-exfat-2t/Movies/files:/files --name volume-test nginx
# in your case
docker run -d -v “/Volumes/eVault/ROM Database/Sony/PS2”:/mnt/ps2games --name volume-test nginx

Then run

container="volume-test"
container_original_config="$(dirname $(docker container inspect "$container" --format '{{ .LogPath }}'))/config.v2.json"
docker run --rm --privileged --pid host ubuntu nsenter --all -t 1 \
  -- ctr -n services.linuxkit task exec --exec-id test 02-docker \
     cat "$container_original_config" \
     | jq .MountPoints

This is what I see:

{
  "/files": {
    "Source": "/host_mnt/Volumes/ta-exfat-2t/files",
    "Destination": "/files",
    "RW": true,
    "Name": "",
    "Driver": "",
    "Type": "bind",
    "Propagation": "rprivate",
    "Spec": {
      "Type": "bind",
      "Source": "/host_mnt/Volumes/ta-exfat-2t/files",
      "Target": "/files"
    },
    "SkipMountpointCreation": false
  }
}

I don’t know if this incorrect free space issue can be solved and if it can, whose job it would be. Docker or the developers of LinuxKit.

Wow! Thank you so much for the detailed response, @rimelek ! I can definitely appreciate the complexity of what’s going on here. There are parts of your response that are over my head for now (I’ll have to take some time to process), but it sounds like the end result is that there are no known workarounds to the issue at this time. Is that right? If so, it sounds like my best bet is to move the affected containers to a linux host. LinuxKit is another new word for me so I’ll read up on that.

If you mean the workaraound is that you use Docker Engine on a Linux machine instead of Docker Desktop, then yes. You would see the size of your actual disk from which you mounted a folder (I tried to make sure).