Docker Toolbox Windows-无效的卷规格 [英] Docker Toolbox Windows - Invalid volume specification
问题描述
编辑:问题是未设置 COMPOSE_CONVERT_WINDOWS_PATHS
环境变量。我尝试将其添加到 Dockerfile
和 .env
文件中,但未设置。我无法设置任何新的环境变量。就像从缓存的Dockerfile构建它一样。
The problem is the COMPOSE_CONVERT_WINDOWS_PATHS
environment variable isn't getting set. I tried adding it to the Dockerfile
and to a .env
file but its not being set. I can't set any new environment variables. Its like its building it from a cached Dockerfile.
删除容器后,我正在运行 docker-composer
,但这并没有重新创建新的容器,即使添加-force-recreate
,它也会从旧的Dockerfile中创建容器。因此我改为运行 docker build ./
,它构建了一个新容器,重新安装了所有软件包,并说正在设置新的环境变量,但是在完成的容器,当我检查运动学时,我看到未设置新的环境变量。但是,当我第一次构建容器时设置的所有旧环境变量都已设置。我不知道为什么会这样,为什么我不能从更新后的Dockerfile创建一个新容器。
I was running docker-composer up
after deleting the container, but this didn't recreate a new container, even when adding --force-recreate
, it created the container from the old Dockerfile. So I ran docker build ./
instead, and it built a new container, it reinstalled all the packages, and it said that it was setting the new environment variables, but in the finished container, when I check kinematic, I see the new environment variables aren't set. But all of the old environment variables that were set when I built the container for the first time, they're all set. I don't know why this is happening, why I can't create a new container from the updated Dockerfile.
我发现了很多有关此错误的线程,尝试在Windows docker-tools中安装卷时发生。当我运行 docker-compose up
时,出现此错误:
I've found a number of threads about this error, it happens when trying to mount a volume in Windows docker-tools. When I run docker-compose up
, I get this error:
ERROR: for web Cannot create container for service web: Invalid bind mount spec "C:\\path\\to\\project:/app:rw": Invalid volume specification: 'C:\path\to\project:/app:rw'
[31mERROR[0m: Encountered errors while bringing up the project.
在 docker-compose
文件中
volumes:
- ./:/app
我尝试设置此环境变量:
I tried setting this environment variable:
COMPOSE_CONVERT_WINDOWS_PATHS=1
到1,因为它在另一个线程中对某些人有效,但在这种情况下不起作用。我尝试在linux这样的格式中添加绝对路径:
to 1, as that worked for some people in another thread but its not working in this case. I tried adding an absolute path in linux like format:
volumes:
- /c/path/to/project:/app
,我收到此错误:
ERROR: for web Cannot create container for service web: create \c\path\to\project: "\\c\\path\\to\\project" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed
请注意,它反斜杠了。更改:
Notice it reversed the forward slashes. Changing:
ENV COMPOSE_CONVERT_WINDOWS_PATHS=0
变为0并没有改变任何东西。
to 0 like that didn't change anything.
如果提供Windows格式的绝对目录,则会再次出现第一个错误。这两个错误,如果我指向一个不存在的目录,就会得到。
If I give a Windows format absolute directory, I get the first error again. Both of those errors, I get them if I point to a directory that doesn't exist.
这里有没有人找到解决此问题的方法?
Has anyone here figured out a way to resolve this?
推荐答案
因此,如果存在此问题,则应创建一个名为COMPOSE_CONVERT_WINDOWS_PATHS的新Windows环境变量,并将其设置为1。或者,您可以在路径docker-compose.yml包含以下内容的路径中创建.env文件:
So, if this problem exists, you should create new Windows environment variable called COMPOSE_CONVERT_WINDOWS_PATHS and set it to 1. Or you can create .env file in the path docker-compose.yml is placed with following content:
COMPOSE_CONVERT_WINDOWS_PATHS=1
..
cat >.env
COMPOSE_CONVERT_WINDOWS_PATHS=1
这篇关于Docker Toolbox Windows-无效的卷规格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!