简体   繁体   中英

docker-compose share volume of other machine

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 -vc:\\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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM