简体   繁体   English

如何使用远程API在Docker容器中挂载主机目录

[英]How to mount host directory in docker container using remote api

Using the docker remote api. 使用docker远程api。 How can i mount a local directory from the machine that's making the request to the the machine that's running docker. 我如何从正在发出请求的计算机上将本地目录挂载到运行docker的计算机上。 Can someone show me an example request to "POST /containers/create" route that mounts a local directory. 有人可以告诉我一个示例请求,该请求请求挂载本地目录的“ POST / containers / create”路由。

You don't, the remote HTTP API request can be coming from anywhere, and doesn't have access to your local drive in the request. 否,远程HTTP API请求可以来自任何地方,并且无法访问该请求中的本地驱动器。 If HTTP gave full access of your local drive to any site you accessed, any malicious website would have full access to your PC without any exploit required. 如果HTTP允许您对访问的任何站点都具有对本地驱动器的完全访问权限,则任何恶意网站都将具有对PC的完全访问权限,而无需任何利用。

To access your drive with a remote request like this, you either need to have that drive mounted on the Docker host (eg VM running the Docker engine), and then mount that, or you need to share your directory, and use a volume driver like NFS to access the remote directory. 要通过这样的远程请求访问驱动器,您需要将该驱动器安装在Docker主机(例如,运行Docker引擎的VM)上,然后进行安装,或者需要共享目录并使用卷驱动程序像NFS一样访问远程目录。

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

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