当目录名称包含冒号时,无法在docker容器中装入卷

时间:2017-09-21 04:09:45

标签: docker docker-volume

当目录名称包含冒号(:)

时,我无法将卷装入docker容器

目录的名称是2012-08-05-00:16:37,我不想重命名目录。我试过了:

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

我收到错误:

docker: Error response from daemon: invalid bind mount spec.See 
'docker run --help'.

如果我重命名目录没有空格或仅使用连字符,那么目录将被装入容器而不会出现任何问题。有人可以指出当目录包含冒号时如何解决问题。

我在Ubuntu:16.04和Docker版本17.06.0-ce。

2 个答案:

答案 0 :(得分:0)

它是Docker的open issue。但在你的情况下,为什么docker run -it --name test1 -v /host_system_path:/container_path image_name不够?

答案 1 :(得分:0)

通过 #include <Imlib2.h> #include <stdlib.h> #include <string.h> #include <stdio.h> int main(int argc, char **argv) { /* an image handle */ Imlib_Image image; /* load the image */ Imlib_Load_Error error; image = imlib_load_image_with_error_return("rgba.raw", &error); printf("load error:%d", error); if (image) { imlib_context_set_image(image); imlib_image_set_format("png"); /* save the image */ imlib_save_image("working.png"); } else { printf("not loaded\n"); } } 指定目录映射时,当前不支持冒号,看来您也无法转义。

您需要改为使用-v

--mount

在最坏的情况下,您当然也可以通过临时系统链接(docker run ... --mount type=bind,source=/some:colon:file,destination=/container-path ... )来解决此限制,或者暂时重命名目标目录。

相关问题