问题
I am trying to mount a network drive as a volume. This is the command I am trying
docker run -v //NetworkDirectory/Folder:/data alpine ls /data
I am running this command on windows and the data directory is coming up empty. How can I mount this network directory as a volume on the windows host and access it inside the container?
Working with local directories works just fine, so the following command works as expected.
docker run -v c:/Users/:/data alpine ls /data
I can make it work in linux since I can mount the share with cifs-utils on a local directory and use that directory as the volume.
Edit: Looks like this is not possible: How to mount network Volume in Docker for Windows (Windows 10)
回答1:
My colleague came up with this and it works with our company network drive and it might help someone out there.
We start by creating a docker volume named mydockervolume.
docker volume create --driver local --opt type=cifs --opt device=//networkdrive-ip/Folder --opt o=user=yourusername,domain=yourdomain,password=yourpassword mydockervolume
--driverspecifies the volume driver name--optSets driver specific options. I guess they are given to the linuxmountcommand when the container starts up.
We can then test that the volume works withdocker run -v mydockervolume:/data alpine ls /data
Here you can read more about driver specific options and docker volume create
回答2:
I didn't find a native CIFS storage driver on docker.
You can use an external volume plugin like this one: https://github.com/ContainX/docker-volume-netshare which support NFS, AWS EFS & Samba/CIFS
来源:https://stackoverflow.com/questions/50239386/docker-add-network-drive-as-volume-on-windows