简体   繁体   English

如何从dockerfile挂载主机卷

[英]How to mount a host volume from dockerfile

I was trying to mount host volume(windows 10) from dockerfile. 我试图从dockerfile挂载主机卷(Windows 10)。 I was using the command: 我正在使用以下命令:

docker run -v <host-dir>:<container-dir> <image-name>

from docker terminal. 从码头码头 It was working fine from docker terminal. 在docker终端上运行正常。 But when I tried to do the same from dockerfile execution it's getting stopped because of this command. 但是,当我尝试从dockerfile执行相同的操作时,由于该命令,该操作已停止。 Please help how to mount host volume from dockerfile. 请帮助如何从dockerfile挂载主机卷。

What exactly have you written in your Dockerfile? 您在Dockerfile中到底写了什么?

For Dockerfiles there exists a VOLUME instruction, which can probably help you. 对于Dockerfiles,存在一条VOLUME指令,可能会对您有所帮助。

I recommend reading the following 2 links for clarification on Docker volumes: 我建议阅读以下2个链接以阐明Docker卷:

Official Docker documentation 官方Docker文档

Helpful blogpost 有用的博客文章

Edit: I may have found another post which could help you immensely: Docker volume and mount 编辑:我可能已经找到了另一篇文章可以极大地帮助您: Docker卷和挂载

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

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