Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

Docker add network drive as volume on windows

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)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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
  • --driver specifies the volume driver name
  • --opt Sets driver specific options. I guess they are given to the linux mount command when the container starts up.

We can then test that the volume works with
docker run -v mydockervolume:/data alpine ls /data

Here you can read more about driver specific options and docker volume create


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...