无法用冒号映射Docker卷 [英] Unable to map docker volume with colon
问题描述
当主机目录路径包含冒号时,是否可以将主机目录作为数据卷挂载? 例子
Is there a way to mount a host directory as a data volume while the host directory path contains a colon? Example
-v /colon:path/test:data
在这种情况下,它将data
视为附加选项. /colon:path/test
是正确的Unix路径.
In that case it's treating data
as additional option. The /colon:path/test
is a correct Unix path.
推荐答案
是.使用--mount
选项,您可以指定源和目标.此选项已添加到Docker 17.05.0.
Yes. With the --mount
option you can specify the source and destination. This option was added to Docker 17.05.0.
--mount type=bind,source=/colon:path/test,destination=/data
注意:您必须使用绝对路径名.我假设目的地是/data.
Note: You must use absolute pathnames. I'm assuming the destination is /data.
在 docker run 联机帮助页中:
另请参阅--mount,它是--tmpfs和--volume的后继. 即使没有计划弃用--volume --mount的用法 建议.
See also --mount, which is the successor of --tmpfs and --volume. Even though there is no plan to deprecate --volume, usage of --mount is recommended.
示例:
touch foo:bar
docker run --rm --mount type=bind,source=$PWD/foo:bar,destination=/tmp/foo:bar busybox ls /tmp
这篇关于无法用冒号映射Docker卷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!