Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 387
iamkawaiineko Avatar asked Mar 16 '26 03:03

iamkawaiineko


1 Answers

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.

like image 51
b0gusb Avatar answered Mar 17 '26 16:03

b0gusb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!