How to Connect Docker Containers to SMB Storage Efficiently?
Asked by
TechyTurtle92
I'm dipping my toes into Docker and Linux, so bear with me. I have my media files stored on an SMB NAS and I'm reworking my Docker setup to use YAML instead of Portainer. What's the best way to connect my Docker containers to the SMB storage? Any advice on this would be really helpful!
Answers
If your NAS has NFS support, you might want to consider that option. NFS tends to be a bit more reliable for Docker containers running on Linux hosts compared to SMB mounts. Though, it might complicate things if your Windows machines need access since they typically donโt handle NFS well.
Reply to this answer
You can either let your host manage the SMB mount and map that volume in your Docker setup, or you can use a Docker network plugin that handles the SMB connection for you.
Reply to this answer
I create the SMB share right on the host and then use bind mounts in my Docker configuration. I find it works perfectly fine without using NFS:
/volume1/video:/video:rw
Then when you're in the container, you just reference it as /video.
Reply to this answer
I personally connect the SMB on the host machine first, then pass that connection to the Docker container. In my compose file, I set it up like this:
volumes:
- /mnt/host_directory:/mnt/container_directory
That way, whatever SMB mount you have on the host will be accessible from the Docker container.
Reply to this answer
Add your answer
Answers are reviewed before publication.
TechyTurtle92: Yeah, that's the issue. Iโd prefer using NFS since it seems better for Docker, but I need my Windows workstations to access the storage, and they're not compatible with NFS.