在OSX中安装Docker音量时,权限被拒绝 [英] Permission denied when mounting Docker volume in OSX

查看:352
本文介绍了在OSX中安装Docker音量时,权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的机智结束了,所以希望你们可以帮助我。在带有docker-machine的OSX 10.11.2中,我有一个docker-compose文件,它应该构建一个本地的Docker文件并附加一个MySQL容器。 MySQL容器应该安装我存储我的数据库数据的本地文件夹,所以如果容器或者VM下来,我可以重新启动它,而不会丢失数据。问题是,当我运行它时,它会抛出一个权限错误:

  db_1 | 2015-12-23 19:17:59 7facaa89b740 InnoDB:文件操作中的操作系统错误号13。 
db_1 | InnoDB:错误意味着mysqld没有
db_1 |的访问权限InnoDB:目录。

我已经尝试过我可以想到的每一个排列,让这个工作。我正在阅读,它可能与Docker-machine如何处理OSX的权限有关,但是docker-machine的文档表示它挂载了 / Users 文件夹,所以不应该是一个问题。



这是$ code> docker-compose.yml :

  web:
build:。
ports:
- 3000:3000
links:
- db
db:
image:mysql:5.6
ports:
- 3306:3306
卷:
- / Users / me / Development / mysql-data:/ var / lib / mysql
环境:
MYSQL_ROOT_PASSWORD:mypass

任何想法?我忍不住想,这真的很简单。任何帮助将不胜感激!



编辑:




  • 主机 - drwxr-xr-x 7我的工作人员238 12月23日12:10 mysql-data /

  • 虚拟机 - code> drwxr-xr-x 1 docker staff 238 Dec 23 20:10 mysql-data /



对于容器,它不会随着装载的卷一起运行。没有 -v mount,它是:




  • 容器 - drwxr-xr-x 4 mysql mysql 4096 Dec 24 00:37 mysql


解决方案

这个问题来自于Mac和Linux分别使用的用户名。 Mac不喜欢Linux想要将1用于userID。



我在Mac + docker-machine设置中处理所有权限的方式是使用这个Dockerfile

  FROM mysql:5.6 

运行usermod -u 1000 mysql
RUN mkdir - p / var / run / mysqld
RUN chmod -R 777 / var / run / mysqld

而不是简单的MySQL 5.6映像。



最后两行是必需的,因为更改mysql用户的用户名将会导致该映像的权限生成。 =>你需要777权限让它运行在这里:/



我知道这是一个有点黑客,但到目前为止,我知道的权限问题的最好的解决方案。


I'm at my wit's end with this, so hopefully you folks can help me. In OSX 10.11.2 with docker-machine, I've got a docker-compose file that should build a local Dockerfile and attach a MySQL container to it. The MySQL container should mount a local folder where I'm storing my database data, so if the container or VM comes down, I can just restart it without data loss. Problem is, when I run it, it throws a permissions error:

db_1  | 2015-12-23 19:17:59 7facaa89b740  InnoDB: Operating system error number 13 in a file operation.
db_1  | InnoDB: The error means mysqld does not have the access rights to
db_1  | InnoDB: the directory.

I've tried every permutation I can think of to get this to work. I was reading around and it may have something to do with how docker-machine handles permissions with OSX, but the documentation for docker-machine says that it mounts the /Users folder, so that shouldn't be an issue.

Here's the docker-compose.yml:

web:
  build: .
  ports:
    - "3000:3000"
  links:
    - db
db:
  image: mysql:5.6
  ports:
    - "3306:3306"
  volumes:
    - /Users/me/Development/mysql-data:/var/lib/mysql
  environment:
    MYSQL_ROOT_PASSWORD: mypass

Any ideas? I can't help but think it's something really simple. Any help would be most appreciated!

Edit:

  • Host - drwxr-xr-x 7 me staff 238 Dec 23 12:10 mysql-data/
  • VM - drwxr-xr-x 1 docker staff 238 Dec 23 20:10 mysql-data/

As to the container, it won't run with the volume mounted. Without the -v mount, it is:

  • Container - drwxr-xr-x 4 mysql mysql 4096 Dec 24 00:37 mysql

解决方案

The issue this comes from is the userids used by Mac and Linux respectively. Mac does not like Linux wanting to use the 1 for the userID.

The way I worked around all the permissions craziness in my mac + docker-machine setup is to use this Dockerfile

FROM mysql:5.6

RUN usermod -u 1000 mysql
RUN mkdir -p /var/run/mysqld
RUN chmod -R 777 /var/run/mysqld

Instead of the plain MySQL 5.6 Image.

The last 2 lines are necessary, because changing the userid for the mysql user will mess up the build in permissions for that image. => you need the 777 permissions to make it run here :/

I know this is a little hacky, but so far the best solution I know to the permissions issue here.

这篇关于在OSX中安装Docker音量时,权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆