Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker-compose : mysqld: Can't create/write to file '/var/lib/mysql/is_writable' (Errcode: 13 - Permission denied)

I'm having an issue when starting the db service with docker compose:

 version: '3'
 services:

 # Mysql DB
    db:
        image: percona:5.7
        #build: ./docker/mysql
        volumes:
          - "./db/data:/var/lib/mysql"
          - "./db/init:/docker-entrypoint-initdb.d"
          - "./db/backups:/tmp/backups"
          - "./shared/home:/home"   
          - "./shared/root:/home"  
        restart: unless-stopped
        environment:
            MYSQL_ROOT_PASSWORD: root
            MYSQL_DATABASE: db_name
            MYSQL_USER: user
            MYSQL_PASSWORD: pass
       ports:
       - "3307:3306"

I have tried everything with no luck:

"./db/data:/var/lib/mysql:rw"

Creating a dockerfile and create from build instead of image:

FROM percona:5.7

RUN adduser mysql
RUN sudo chown mysql /var/lib/mysql
RUN sudo chgrp mysql /var/lib/mysql

Also I have tried to add a user on db service:

user: "1000:50"

But any of those could solve that.. What I'm missing?

MySQL 5.7 installation error `mysqld: Can't create/write to file '/var/lib/mysql/is_writable'`

like image 780
Albeis Avatar asked Feb 03 '19 21:02

Albeis


1 Answers

I had to change ./db/data user:group to 999:999, so docker user is who is making the changes.

sudo chown 999:999 ./db/data
like image 65
Albeis Avatar answered Oct 23 '22 03:10

Albeis