gpt4 book ai didi

docker - docker-compose问题:尝试创建/装入卷时权限被拒绝

转载 作者:行者123 更新时间:2023-12-02 21:11:45 34 4
gpt4 key购买 nike

我有以下docker-compose.yml文件:

version: "3"
services:
dbs-poa-loc001d:
image: percona
volumes:
- ./mysql_backup:/var/lib/mysql
- ./create_databases:/docker-entrypoint-initdb.d
hostname: "dbs-poa-loc001d"
container_name: dbs-poa-loc001d
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: "yes"
ports:
- "3306:3306"
networks:
- azion-network
...

当我尝试创建dbs-poa-loc001d服务(该项目的数据库)时,出现以下错误:
Starting dbs-poa-loc001d ... done
Attaching to dbs-poa-loc001d
dbs-poa-loc001d | Initializing database
dbs-poa-loc001d | mysqld: Can't create/write to file '/var/lib/mysql/is_writable' (Errcode: 13 - Permission denied)
dbs-poa-loc001d | 2019-01-11T01:17:52.060984Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
dbs-poa-loc001d | 2019-01-11T01:17:52.062286Z 0 [ERROR] --initialize specified but the data directory exists and is not writable. Aborting.
dbs-poa-loc001d | 2019-01-11T01:17:52.062299Z 0 [ERROR] Aborting
dbs-poa-loc001d |
dbs-poa-loc001d exited with code 1

在我的工作中,我的MacOS计算机上不会发生此错误,但是在我的家用计算机(运行Ubuntu 16.04)中会发生此错误。我确实注意到创建的用于保存卷数据的主机上的 mysql_backup文件夹设置为组AND用户root。谁能告诉我发生了什么,如何解决?已经尝试不成功:
  • 使用sudo
  • 运行docker-compose命令
  • 手动将文件夹的所有者和用户更改为我的实际(低特权)用户。

  • 我当前的安装和安装版本是:
  • Ubuntu 16.04
  • Docker 18.09.0版,内部版本4d60db4
  • docker-compose版本1.23.2,内部版本1110ad0
  • 使用 sudo pip install docker-compose 安装了
  • docker-compose

  • 最佳答案

    您可以尝试将mysql_backup的权限设置为1001:0吗?
    sudo chown -R 1001:0 ./mysql_backup这样的东西
    或作为替代,但仅当文件夹为空 sudo chmod 777 ./mysql_backup时才使用

    关于percona Dockerfile mysql用户ID为1001
    https://github.com/percona/percona-docker/blob/master/percona-server.80/Dockerfile

    关于docker - docker-compose问题:尝试创建/装入卷时权限被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54139202/

    34 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com