Docker on MacOS with an SMB File Share

For a while now I’ve been running my whole home server stack on Docker on a Mac Mini.

My setup consists of the Mac Mini and a QNAP NAS. The NAS is where the large volumes of data are stored for the docker containers to access and serve content from.

Every now and again, my containers would stop functioning and an error message would appear with something to the effect of “too many open files”.

Additionally, whenever files or folders would be deleted by any of the containers I would see strange hidden files in the NAS like .smbdeleteAAA* that were the size of the files being deleted. Those often would not go away.

I believe my issue to be two things:

  1. Using MacOS file share as the mount.
  2. Potentially file permission issues.

Let’s dive deeper in to each of these things.

Mounting:

  1. To mount the folder better, instead of mounting a file share on Mac OS and then binding like this:
/Volume/Share/Folder:/folder

I now mount with the docker compose like this:

services:
  service:
    image: <image>
    volumes:
      - type: volume
        source: nas_mount
        target: /container_folder_name
        volume:
          subpath: SubfolderInNAS

volumes:
  nas_mount:
    driver: local
    driver_opts:
      type: cifs
      device: "//<ip of NAS>/Folder"
      o: "addr=<ip of NAS>,username=user,password=password,file_mode=0777,dir_mode=0777"

The key benefit here, is that Docker now uses it’s own implementation of SMB which seems to be more stable and not produce weird .smbdelete* files and is able to immediately delete things.

File Permissions:

I was unable to delete some files from the share through the containers, but after performing a recursive file permission update on the NAS, the issue was resolved. I suspect that many of these files were not created or updated by the containers. Since they were migrated from a Windows host, they may have had some unusual permissions.

Leave a Reply

Your email address will not be published. Required fields are marked *