Docker-compose:mysqld:无法创建/写入文件“/var/lib/mysql/is_writable"(错误代码:13 - 权限被拒绝)

Docker-compose : mysqld: Can#39;t create/write to file #39;/var/lib/mysql/is_writable#39; (Errcode: 13 - Permission denied)(Docker-compose:mysqld:无法创建/写入文件“/var/lib/mysql/is_writable(错误代码:13 - 权限被拒绝))
本文介绍了Docker-compose:mysqld:无法创建/写入文件“/var/lib/mysql/is_writable"(错误代码:13 - 权限被拒绝)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 docker compose 启动数据库服务时遇到问题:

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"

创建一个 dockerfile 并从构建而不是图像创建:

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

我还尝试在 db 服务上添加用户:

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 安装错误`mysqld: Can't create/write to file '/var/lib/mysql/is_writable'`

推荐答案

我不得不将 ./db/data user:group 更改为 999:999,因此 docker 用户是进行更改的人.

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

这篇关于Docker-compose:mysqld:无法创建/写入文件“/var/lib/mysql/is_writable"(错误代码:13 - 权限被拒绝)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Hibernate reactive No Vert.x context active in aws rds(AWS RDS中的休眠反应性非Vert.x上下文处于活动状态)
Bulk insert with mysql2 and NodeJs throws 500(使用mysql2和NodeJS的大容量插入抛出500)
Flask + PyMySQL giving error no attribute #39;settimeout#39;(FlASK+PyMySQL给出错误,没有属性#39;setTimeout#39;)
auto_increment column for a group of rows?(一组行的AUTO_INCREMENT列?)
Sort by ID DESC(按ID代码排序)
SQL/MySQL: split a quantity value into multiple rows by date(SQL/MySQL:按日期将数量值拆分为多行)