首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >docker-撰写问题:尝试创建/挂载卷时被拒绝的权限

docker-撰写问题:尝试创建/挂载卷时被拒绝的权限
EN

Stack Overflow用户
提问于 2019-01-11 01:27:46
回答 1查看 9.2K关注 0票数 0

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

代码语言:javascript
复制
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服务(项目的数据库)时,我会得到以下错误:

代码语言:javascript
复制
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计算机上,而是在我的家用计算机(运行Ubuntu16.04)上。我确实注意到,为保存卷数据而创建的主机上的mysql_backup文件夹被设置为组和用户根。有人能告诉我发生了什么事吗?我该怎么解决呢?已试过但未成功:

  • 运行docker-使用sudo编写命令
  • 手动将文件夹的所有者和用户更改为实际(低特权)用户。

我现在的安装和安装版本是:

  • Ubuntu 16.04
  • Docker版本18.09.0,构建4d60db4
  • docker-构建版本1.23.2,构建1110ad0
  • 使用sudo pip install docker-compose安装了docker
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-01-11 01:56:55

您能否尝试将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

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54139202

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档