在Docker中创建和绑定安装文件

发布于 2025-02-07 08:05:20 字数 382 浏览 0 评论 0原文

docker关于绑定安装的文档说明:

Docker主机上不需要该文件或目录。如果不存在,它是按需创建的。

文件夹是正确的:如果我将安装绑定为:

docker run -v $ pwd/mydir:/mydir映像:版本

,然后创建mydir文件夹并绑定在容器中。但是我找不到在上面链接页面或其他任何地方对文件做同样的事情的语法。

The Docker documentation about bind mounts states that:

The file or directory does not need to exist on the Docker host already. It is created on demand if it does not yet exist.

This is true for folders: if I bind mount as:

docker run -v $PWD/mydir:/mydir image:version

then the mydir folder is created and bind mounted in the container. But I cannot find the syntax for doing the same thing for a file either at the above linked page nor anywhere else.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烟沫凡尘 2025-02-14 08:05:20

文档不一致。上面有一个空旷的问题: https://github.com/docker.com/docker.com/docker/docker/docker/docker/docker/docker/docker 。

​或使用- MOUNT语法会失败。

The documentation is inconsistent. There's an open issue on it: https://github.com/docker/docker.github.io/issues/10133

Docker always creates a directory if the host path doesn't exist. Or fails if you use the --mount syntax.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文