How to Mount an SMB Share to a Docker Container (Step-by-Step)

🧱 Step 1: Mount SMB Share on Host (Linux Example)

Run this on your Docker host (Linux):

sudo mount -t cifs //SERVER_IP/SHARE_NAME /mnt/smb \
  -o username=USERNAME,password=PASSWORD,uid=1000,gid=1000,vers=3.0
  • Replace //SERVER_IP/SHARE_NAME with your SMB path.
  • Adjust uid, gid to match your Docker container user (commonly 1000).
  • Use vers=3.0, 2.1, or 1.0 depending on the SMB server.

πŸ‘‰ You can also make this mount persistent in /etc/fstab.


🐳 Step 2: Run Docker Container with SMB Mount

Now mount the local directory (e.g., /mnt/smb) into your container:

docker run -v /mnt/smb:/data/smb-share my-n8n-container

Inside the container, /data/smb-share will map to your SMB share.


🧠 Notes

  • Permissions: Make sure the user running inside the container has read/write access to the mounted path. Learn more
  • Docker Compose example:
services:
  n8n:
    image: n8nio/n8n
    volumes:
      - /mnt/smb:/data/smb-share
  • Alternative: Use smbclient inside the container to interact with the share via commands, but that’s read/write only at runtime, not a mounted path.

βœ… Use Case in n8n

If you’re exporting a CSV file using Write Binary File, set the path to something like:

/data/smb-share/export.csv

This will write directly to your SMB share via the mounted volume.


Comments

Leave a Reply

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