问题
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