4

I'm trying to bind mount a network drive from my host (Windows 10) to a local folder in a container but, regrettably, I haven't been able to achieve it.

In Linux I've had no issues whatsoever.

Any help would be greatly appreciated :)

docker run -v G:/:mnt/shared ubuntu /bin/bash
Obsidian
  • 3,719
  • 8
  • 17
  • 30
Jordi
  • 51
  • 1
  • 4
  • Possible duplicate of [Docker add network drive as volume on windows](https://stackoverflow.com/questions/50239386/docker-add-network-drive-as-volume-on-windows) – RobC Sep 05 '19 at 07:21

2 Answers2

1

For local drive, use the following command:

docker run -v c:/your-directory/:/mnt/shared ubuntu /bin/bash

For network drive, you need to create a Docker volume pointing to that network drive.

The command would be as follows:

docker volume create --driver local --opt type=cifs --opt device=//networkdrive-ip/Folder --opt o=user=yourusername,domain=yourdomain,password=yourpassword mydockervolume
docker run -v mydockervolume:/data alpine ls /data

Reference is here: How to Add Network Drive as Volume in Docker on Windows

Abdullah Khawer
  • 4,461
  • 4
  • 29
  • 66
  • First of all, thanks for your help! I ran your command but it didn't work. I got this error: C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: Drive sharing failed for an unknown reason. See 'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'. Any ideas? – Jordi Sep 05 '19 at 06:13
  • You might have to create a Docker volume, I guess. By the way, I'm glad you found a solution that worked for you. – Abdullah Khawer Sep 05 '19 at 07:53
  • 1
    thank you! spent almost 2 days looking for this answer. – Hp93 Oct 15 '20 at 07:32
1

I managed to do it in a different way.

Here is the answer: Docker add network drive as volume on windows

Abdullah Khawer
  • 4,461
  • 4
  • 29
  • 66
Jordi
  • 51
  • 1
  • 4