问题描述
我在使用 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 - 权限被拒绝)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!