简体   繁体   English

docker-compose其他机器的共享量

[英]docker-compose share volume of other machine

I am using docker which created on windows 10 (The docker is for linux). 我正在使用在Windows 10上创建的docker(docker用于linux)。

Also, using docker-compose (Version 3.4) to map a volumes that is outside docker into the docker container. 此外,使用docker-compose(版本3.4)将docker之外的卷映射到docker容器中。

I have a shared folder on another computer, that I want to use in the docker. 我在另一台计算机上有一个共享文件夹,我想在docker中使用它。

I check the access of that folder, and I can access it from the computer the docker is running. 我检查该文件夹的访问权限,我可以从Docker正在运行的计算机上访问它。

//ip_addr/shared_folder // ip_addr中/ shared_folder

In docker-compose, I wrote: 在docker-compose中,我写道:

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? 并且ip 1.2.3.4是my_folder的ip?

... 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. 如何将其他计算机共享文件夹映射到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. 我正在尝试在Windows 10中创建一个符号链接并将其附加到docker,但这对我没有太大帮助,因为我遇到异常。

In windows command line I did: 在Windows命令行中我做了:

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). 当运行docker时(我有docker社区版本18.06.1-ce-win73(19507) - linux容器)。

In command line, I have tried to run alpine (that's happens also on other dockers based on linux images): 在命令行中,我试图运行alpine(这也发生在基于linux映像的其他docker上):

docker run -i -t -vc:\\test_ext:/data:rw alpine /bin/sh I get the error: docker run -i -t -vc:\\ test_ext:/ data:rw alpine / bin / sh我收到错误:

docker: Error response from daemon: error while creating mount source path '/host_mnt/c/test_ext': mkdir /host_mnt/c/test_ext: file exists. docker:来自守护程序的错误响应:创建安装源路径'/ host_mnt / c / test_ext'时出错:mkdir / host_mnt / c / test_ext:文件存在。

That's only happen for external IP. 这只发生在外部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. 我尝试了一些解决方法,例如:docker volumes prune,但这没什么用处。

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 靠近volumes: - ./my_folder:my_docker_folder

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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