简体   繁体   中英

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. 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

docker-compose up

Creating ziegel24_database_1... error

ERROR: for ziegel24_database_1 Cannot create container for service database: invalid mode: /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.

the docker-compose.yml is the following

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. (Mysql is on a newer version but since docker creates a new database it would pull the needed sql version I was told)

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?

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. 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. If the host path contains a colon ( : ) CONTAINER is interpreted as access mode.

In your case ./mysql/db/entrypoint is a relative path and docker expands it to full path. 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.

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.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM