Unable to map docker volume with colon

风格不统一 提交于 2019-12-23 22:01:18

问题


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

In that case it's treating data as additional option. The /colon:path/test is a correct Unix path.


回答1:


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

Note: You must use absolute pathnames. I'm assuming the destination is /data.

From the docker run manpage:

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.

Example:

touch foo:bar
docker run --rm --mount type=bind,source=$PWD/foo:bar,destination=/tmp/foo:bar busybox ls /tmp


来源:https://stackoverflow.com/questions/44938108/unable-to-map-docker-volume-with-colon

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!