6

I am using docker which created on windows 10 (The docker is for linux).

Also, using docker-compose (Version 3.4) to map a volumes that is outside docker into the docker container.

I have a shared folder on another computer, that I want to use in the docker.

I check the access of that folder, and I can access it from the computer the docker is running.

//ip_addr/shared_folder

In docker-compose, I wrote:

volumes:
  - //1.2.3.4/my_folder:my_docker_folder

I found some syntax with networks declaration. I don't know how exactly shall I write?

volumes:
  - /my_folder:my_docker_folder
networks:
  frontend:
    ipv4_address: 1.2.3.4

and that ip 1.2.3.4 is the ip for my_folder?

... but this syntax may not be correct, or I should run some commands to share the folder correctly.

What to do in order to map the other computer shared folder to the docker.

I have tried several things, also mapping a symbolic link.

I am trying create a symbolic link in windows 10 and attach it to docker, but this doesn't much helped me, since I encountered into exception.

In windows command line I did:

mklink /D c:\test_ext \\ip\shared_folder

When running the docker (I have the docker community edition Version 18.06.1-ce-win73 (19507) - linux container).

In command line, I have tried to run alpine (that's happens also on other dockers based on linux images):

docker run -i -t -v c:\test_ext:/data:rw alpine /bin/sh I get the error:

docker: Error response from daemon: error while creating mount source path '/host_mnt/c/test_ext': mkdir /host_mnt/c/test_ext: file exists.

That's only happen for external IP.

What I see, is that the folder+subfolders+files is shared with full permissions.

I have tried some work around, such as: docker volumes prune, but this didn't much help.

Why is that error message, and how can I resolve that?

I found also, an alternative that may help:

docker volume create \
  --driver local \
  --opt type=nfs \
  --opt o=addr=ip_address,rw \
  --opt device=:/myfolder 
   my_volume

This doesn't solve the problem either (syntax is wrong).

Thanks.

Eitan
  • 1,286
  • 2
  • 16
  • 55
  • Just to make debugging easier, if I were you I'd try changing to the long syntax https://docs.docker.com/compose/compose-file/#volumes this however does look like your issue is just how windows works with network drives rather than docker. But I can't be sure as I haven't used docker in this way. – Shardj Dec 07 '18 at 09:40
  • You can write c# core in windows, but the docker is suitable for linux. Just put the //machine_name or //ip_name as source, but it seems not to be the correct syntax (or it is the correct syntax, but I need to do some extra steps). – Eitan Dec 07 '18 at 14:56
  • Do you have the same issue with the long syntax from the documentation I linked? Also worth checking your versions to make sure you're up to date since long syntax was added not that long ago – Shardj Dec 07 '18 at 15:10
  • I use version 3.4. I don't use web. Just a folder shared on another computer. Still I didn't understand what syntax can solve this issue. Any good yml sample for exactly situation which I want to use shared folder of another computer from the current folder? – Eitan Dec 07 '18 at 20:55
  • I found: that network may be the solution. I don't know how exactly shall I write? volumes: - /my_folder:my_docker_folder networks: frontend: ipv4_address: 1.2.3.4 and that ip 1.2.3.4 is the ip for my_folder. Is that the correct syntax? is there any good example for that? – Eitan Dec 07 '18 at 21:43
  • This is a very good question, curious myself the answer. – Joseph Astrahan Dec 07 '18 at 21:46
  • I edited my post accordinally. Why simple thing of sharing files, may be complicated issue. I am sure there must be a syntax way doing that. – Eitan Dec 07 '18 at 21:56
  • I think I can install samba into the docker, and may use it in docker-compose (in some manner). How can I map an external volume in docker in that way? – Eitan Dec 09 '18 at 08:10
  • The solution may be related to creating symbol links or volumes with mapping. I tried that way, but I encountered into a new problem, https://stackoverflow.com/questions/53703329/create-a-symbolic-link-in-windows-and-attach-it-to-docker – Eitan Dec 10 '18 at 12:39
  • Maybe try using the [Netshare](https://github.com/ContainX/docker-volume-netshare) plugin? [#39922331](https://stackoverflow.com/a/39922331/6085135) – brennan Dec 16 '18 at 14:55

1 Answers1

-2

I think you need to give . near the volume volumes: - ./my_folder:my_docker_folder