databasedockerdocker-composemariadbdocker-entrypoint

Docker Compose - Entrypoint permission error (mariadb)


I have tried many things and searched for this it, but nobody seems to have my exact problem.

I installed docker on my Ubuntu 20.04 LTS using these steps and the test run docker run hello-world works perfect.

My docker-compose.yml looks like this:

version: '3.7'

services:

  db:
    image: mariadb
    environment:
      MYSQL_ROOT_PASSWORD: 42
    volumes:
      - type: bind
        source: ./dbsetup
        target: /docker-entrypoint-initdb.d

  adminer:
    image: adminer
    ports:
      - 8080:8080
    depends_on:
      - db

The docker service is running and mariadb/adminer images download without error.

When I try to use docker compose up (sudo or not) I get the following error:

Attaching to dbexercise3-adminer-1, dbexercise3-db-1
dbexercise3-db-1       | 2022-11-26 01:01:54+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.10.2+maria~ubu2204 started.
dbexercise3-db-1       | 2022-11-26 01:01:54+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
dbexercise3-db-1       | 2022-11-26 01:01:54+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.10.2+maria~ubu2204 started.
dbexercise3-db-1       | ls: cannot open directory '/docker-entrypoint-initdb.d/': Permission denied
dbexercise3-adminer-1  | [Sat Nov 26 01:01:54 2022] PHP 7.4.33 Development Server (http://[::]:8080) started
dbexercise3-db-1 exited with code 2

Adminer starts as it should, however I can't log in (because the mariadb container doesn't exist).

I also tried installing Docker Desktop.
After I start the GUI application docker compose up works and I can work with the DB. Of course I could simply use Docker Desktop and start it on boot, but I don't need the GUI and the need to manually update via DEB-package is annoying.


Solution

  • The answer was surprisingly easy.

    I simply hat to run chmod 777 dbsetup to clear the permission error. I still have no idea how Docker Desktop managed to circumvent this issue, maybe because it runs a task which gives it higher priority?