[英]SMB/CIFS volume in Docker-compose on Windows
我有一個共享 CIFS/SMB 共享的 NAS,我想在 Windows 上使用 docker-compose 將其掛載為卷。
我已經閱讀了多項建議(例如使用插件,將其安裝在 Windows 中以提供驅動器號),但沒有找到任何可以工作的東西。 我知道這不是 100% 簡單的,因為我是從另一個操作系統內部訪問它。 但這聽起來應該是可能的。
So say that I have a network path, \\my-nas\share
, how would I go about mounting this inside a docker container using docker-compose on a Windows host?
我完全誤解了這個 docker 文檔頁面,上面寫着
The built-in local driver on Windows does not support any options.
這並不意味着您不能在 Windows 中使用 cifs 驅動程序。
解決方法很簡單
services:
my-service:
volumes:
- nas-share:/container-path
volumes:
nas-share:
driver_opts:
type: cifs
o: "username=[username],password=[password]"
device: "//my-nas/share"
將[username]
和[password]
替換為 NAS 的實際用戶名和密碼,它可以完美運行。
這對我使用 WindowsServer2019 主機上的 windows 容器很有用。 它需要版本 1705 或更高版本:
https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/persistent-storage#bind-mounts
首先將文件共享掛載到主機。
$creds = Get-Credential New-SmbGlobalMapping -RemotePath \contosofileserver\share1 -Credential $creds -LocalPath G:
然后 map 驅動器正常組成:
services:
my-service:
volumes:
- Z:\:/container-path
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.