Docker Toolbox(Windows):无效的卷规格 [英] Docker Toolbox (Windows): invalid volume specification
问题描述
配置
使用Windows 10,Docker工具箱(非本机Docker,以便能够使用VM).
背景
有一个Python(2.7)脚本应该运行Docker容器.代码如下:
self.docker.containers.run('container_name',command ='bash -c%s"'%命令,volume = {PROJECT_PATH:{'bind':'/shared','mode':'rw'}},working_dir ='/shared',remove = True,** kwargs)
问题
尝试运行脚本:
*构建DummyProbe泊坞窗映像*运行DummyProbe容器500服务器错误:内部服务器错误(无效的卷规范:'C:\ Users \ Foo \ ..:/shared:rw'")
想法
在网上搜索后,无效的卷规范
似乎是由Windows和Linux处理目录结构的方式引起的.Linux使用斜杠/
,而Windows使用反斜杠 \
.类似的问题:
-
Docker Toolbox
$ docker-machine env导出DOCKER_TLS_VERIFY ="1"导出DOCKER_HOST ="tcp://111.111.11.111:1111"导出DOCKER_CERT_PATH ="C:\ Users \ Foo \ .docker \ machine \ machines \ default"导出DOCKER_MACHINE_NAME =默认"导出COMPOSE_CONVERT_WINDOWS_PATHS ="true"#运行以下命令以配置您的shell:#eval $("C:\ Program Files \ Docker Toolbox \ docker-machine.exe" env)
其他问题中的任何建议都行不通.
更新
试图用
/
替换\
并在脚本中使用它:500服务器错误:内部服务器错误(无效的卷规范:'C:/Users/***/..:/shared:rw'")
所以看来这不是问题
解决方案我能够通过用
/
和C替换所有
和\\
来完成这项工作:/c
.断开路径:
C:\\ Path \\ to \\ file
变成/c/path/to/file
https://docs.python.org/2/library/os.html
似乎负责返回系统路径的
os
模块没有将Windows转换为Unix路径的内置函数.Docker Toolbox也无法处理这种对话(即使可以的话).也许还有其他一些优雅的方法可以完成这项工作.但是现在只使用这个.
Configration
Using Windows 10, Docker Toolbox (not native Docker, to be able to use VMs).
Background
There is a Python (2.7) script that is supposed to run a Docker container. The code looks like this:
self.docker.containers.run('container_name', command='bash -c "%s"' % command, volumes={PROJECT_PATH: {'bind': '/shared', 'mode': 'rw'}}, working_dir='/shared', remove=True, **kwargs)
Problem
Trying to run the script:
* Building the DummyProbe docker image * Running the DummyProbe container 500 Server Error: Internal Server Error ("invalid volume specification: 'C:\Users\Foo\..:/shared:rw'")
Thoughts
After searching the web the
invalid volume specification
is seems to be caused by the way Windows and Linux handle directory structure. Linux uses slashes/
while Windows - back-slashed\
. Similar questions:- Docker Toolbox Windows - Invalid volume specification
- Invalid volume specification trying to run portainer container
However in my case the
COMPOSE_CONVERT_WINDOWS_PATHS
is set (totrue
, tried setting to1
as well):PowerShell
Docker Toolbox
$ docker-machine env export DOCKER_TLS_VERIFY="1" export DOCKER_HOST="tcp://111.111.11.111:1111" export DOCKER_CERT_PATH="C:\Users\Foo\.docker\machine\machines\default" export DOCKER_MACHINE_NAME="default" export COMPOSE_CONVERT_WINDOWS_PATHS="true" # Run this command to configure your shell: # eval $("C:\Program Files\Docker Toolbox\docker-machine.exe" env)
None of the suggestions in other questions work.
Update
Tried to use to replace
\
with/
and use it in script:500 Server Error: Internal Server Error ("invalid volume specification: 'C:/Users/***/..:/shared:rw'")
So it seems like it is not an issue
解决方案I was able to make this work by replacing all
\\
with/
andC:
with/c
.The broken path:
C:\\Path\\to\\file
becomes/c/path/to/file
https://docs.python.org/2/library/os.html
It seems that
os
module which is responsible for returning system paths doesn't have a built-in func to convert Windows to Unix path. And the Docker Toolbox doesn't handle this converstion as well (if it even should).May be there is some other elegant way to make this work. But for now going to just use this one.
这篇关于Docker Toolbox(Windows):无效的卷规格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!