[英]docker-compose up invalid mode /docker-entrypoint-initdb.d/ - cannot create container for service database
I have to use docker-compose up to start a database.我必须使用 docker-compose up 来启动数据库。 Everything we needed for that is already given and it works for my partners.我们为此所需的一切都已经提供,并且对我的合作伙伴有用。 Meanwhile I have the following problem.同时我有以下问题。 (I'm using Mac OS Catalina btw) Every time I try to use docker-compose up the following error occurs (我正在使用 Mac OS Catalina 顺便说一句)每次我尝试使用 docker-compose up 时都会发生以下错误
docker-compose up码头工人组成
Creating ziegel24_database_1... error创建 ziegel24_database_1...错误
ERROR: for ziegel24_database_1 Cannot create container for service database: invalid mode: /docker-entrypoint-initdb.d/错误:对于 ziegel24_database_1 无法为服务数据库创建容器:无效模式:/docker-entrypoint-initdb.d/
ERROR: for database Cannot create container for service database: invalid mode: /docker-entrypoint-initdb.d/ ERROR: Encountered errors while bringing up the project.错误:对于数据库无法为服务数据库创建容器:无效模式:/docker-entrypoint-initdb.d/ 错误:启动项目时遇到错误。
the docker-compose.yml is the following docker-compose.yml 如下
version: "3.1"
services:
database:
image: mysql:5.7
volumes:
- ./mysql/db/entrypoint:/docker-entrypoint-initdb.d/
ports:
- "3308:3306"
environment:
- "MYSQL_ROOT_PASSWORD=geheim"
- "MYSQL_DATABASE=Ziegel24"
I have already checked if my docker compose and engine are the correct version which they are.我已经检查过我的 docker compose 和 engine 是否是正确的版本。 (Mysql is on a newer version but since docker creates a new database it would pull the needed sql version I was told) (Mysql 是一个较新的版本,但由于 docker 创建了一个新的数据库,它会拉取所需的 sql 版本,我被告知)
I also have tried to locate the said docker-entrypoint-initdb.d directory but even running find on my whole computer didn't give results, so I guess the whole directory is not there?我也试图找到所说的 docker-entrypoint-initdb.d目录,但即使在我的整个计算机上运行 find 也没有给出结果,所以我猜整个目录不在那里?
Is there any way to download it manually or does it come in a package I mistakenly didn't install?有没有办法手动下载它,或者它是否包含在我错误地没有安装的包中?
EDIT I've realised the docker-entrypoint-initdb.d shouldn't be on my computer anyway, but in the mysql:5.7 image.编辑我已经意识到 docker-entrypoint-initdb.d 无论如何都不应该在我的电脑上,而是在 mysql:5.7 图像中。 I still don't know what the exact error is and how to fix it but yeah that's new.我仍然不知道确切的错误是什么以及如何修复它,但是是的,这是新的。
Since I didn't find any help when I searched my error I came here for help.由于我在搜索错误时没有找到任何帮助,所以我来这里寻求帮助。
The short syntax for volumes is (HOST:CONTAINER)
or (HOST:CONTAINER:ro)
if access mode is specified.如果指定了访问模式,卷的简短语法是(HOST:CONTAINER)
或(HOST:CONTAINER:ro)
。 If the host path contains a colon ( :
) CONTAINER
is interpreted as access mode.如果主机路径包含冒号 ( :
,则CONTAINER
被解释为访问模式。
In your case ./mysql/db/entrypoint
is a relative path and docker expands it to full path.在您的情况下./mysql/db/entrypoint
是相对路径,docker 将其扩展为完整路径。 If this full path contains a colon, /docker-entrypoint-initdb.d/
is considered the access mode which is obviously invalid (allowed values are ro
and rw
), hence the error.如果此完整路径包含冒号, /docker-entrypoint-initdb.d/
被视为显然无效的访问模式(允许的值为ro
和rw
),因此会出现错误。
This might not be your case but I could reproduce the behaviour above with Docker version 18.04.0-ce, build 3d479c0 and docker-compose version 1.21.0, build 5920eb0 on Ubuntu 14.04.5 LTS.这可能不是你的情况,但我可以在 Ubuntu 14.04.5 LTS 上使用 Docker 版本 18.04.0-ce、build 3d479c0 和 docker-compose 版本 1.21.0、build 5920eb0 重现上述行为。
Hope this helps.希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.