Reputation: 551
I cannot mount a volume to a docker container when the directory name contains a colon (:)
The name of the directory is 2012-08-05-00:16:37 and I prefer not renaming the directory. I tried:
docker run -it --name test1 \
-v /host_system_path/2012-08-05-00\:16\:37/:/container_path/2012-08-05-00\:16\:37/
image_name
I get the error:
docker: Error response from daemon: invalid bind mount spec.See
'docker run --help'.
If I rename the directory without spaces or only with hyphens, then the directory is mounted into the container without any issues. Can someone point out how can I solve the problem when the directory contains a colon.
I am on Ubuntu:16.04 and Docker version 17.06.0-ce.
Upvotes: 2
Views: 3085
Reputation: 10852
Colons are currently not supported when specifying directory mappings via -v
, and it seems you cannot escape them either.
You need to leverage --mount
instead:
docker run ... --mount type=bind,source=/some:colon:file,destination=/container-path ...
In the worst of cases, you may of course alternatively still work around this limitation with a temporary system link (ln -s
) or rename the target directory temporarily.
Upvotes: 2
Reputation: 5307
It's an open issue with Docker. But in your case, why would docker run -it --name test1 -v /host_system_path:/container_path image_name
not be sufficient?
Upvotes: 1