本地卷名的docker无效字符 [英] docker invalid characters for local volume name
问题描述
几天前,我在新笔记本电脑上安装了docker。我使用docker已经有一段时间了,并且非常了解基本知识。但是,由于某种原因,我一直遇到同样的问题,希望这里有人能帮助我。
A few days ago, I installed docker on my new laptop. I've used docker for a while and know the basics pretty well. Yet, for some reason I keep bumping into the same problem and I hope someone here can help me.
在Windows 10 Home笔记本电脑上安装Docker Toolbox之后,我尝试了运行一些我使用docker-compose.yml创建的图像。由于Windows上的用户目录中包含我的确切名称(C:/ Users / Nick van der Meij),并且该名称包含空格,因此我在Docker Host上从C:/ code到/ mnt / code添加了一个额外的共享文件夹(这有效)。我已使用此指南这样做
After installing the Docker Toolbox on my Windows 10 Home laptop, I tried to run some images that I've created using a docker-compose.yml. Since my user directory on windows has my exact name in it (C:/Users/Nick van der Meij) and that name contains spaces, I added an extra shared folder from C:/code to /mnt/code on the Docker Host (this works). I've used this guide to do so
但是,当我尝试运行docker-compose.yml(包括以下内容)时,出现以下错误:
However, when I try to run my docker-compose.yml (included below), I get the following error:
ERROR: for php Cannot create container for service php: create \mnt\code\basic_php\api: "\\mnt\\code\\basic_php\\api" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed
[31mERROR[0m: Encountered errors while bringing up the project.
据我所见,根据有关体积的官方docker文档,一切似乎都是正确的。我花了很多时间试图解决此问题,并为卷标记尝试了多种格式,但没有成功。
As far as I see it, everything seems to be correct according to the official docker docs about volumes. I've spend many hours trying to fix this and tried out multiple "formats" for the volumes tag, yet without any success.
有人知道这个问题可能是什么吗? ?
Does anyone know what the problem might be?
预先感谢!
docker-compose.yml
docker-compose.yml
version: '2'
services:
mysql:
image: mysql:5.7
ports:
- 3306
volumes:
- /var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_USER: user
MYSQL_PASSWORD: password
MYSQL_DATABASE: database
nginx:
image: nginx:1.10.2
ports:
- 80:80
- 443:443
restart: always
volumes:
- /mnt/code/basic_php/nginx/conf:/etc/nginx/conf.d
- /mnt/code/basic_php/api:/code/api
- /mnt/code/basic_php/nginx:/code/nginx
links:
- php
- site
depends_on:
- php
- site
php:
build: php
expose:
- 9000
restart: always
volumes:
- /mnt/code/basic_php/php/conf/php.ini:/usr/local/etc/php/conf.d/custom.ini
- /mnt/code/basic_php/api:/code/api
links:
- mysql
site:
restart: always
build: site
ports:
- 80
container_name: site
推荐答案
在网上搜索了几个小时之后,我终于找到了我想要的东西。就像沃尔夫冈·布莱森(Wolfgang Blessen)在我的问题下方的评论中所说的那样,该问题确实是Windows路径问题。
After a few hours searching the web, I finally found what i was looking for. Like Wolfgang Blessen said in the comments below my question, the problem was indeed a Windows Path problem.
如果您不希望docker自动将路径窗口转换为unix,则需要添加值为0的COMPOSE_CONVERT_WINDOWS_PATHS环境变量,如下所述:链接
If you dont want docker to automatically convert paths windows to unix, you need to add the COMPOSE_CONVERT_WINDOWS_PATHS environment variable with a value of 0 like explained here: link
这篇关于本地卷名的docker无效字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!