Permission denied when setting docker volume in OSX

I am at my end with this, so I hope you people can help me. In OSX 10.11.2 with a docking machine, I have a file containing dockers that should create a local Docker file and attach a MySQL container to it. The MySQL container must mount the local folder where I store the data of my database, so if the container or virtual machine is lowered, I can simply restart it without losing data. The problem is that when I run it, it throws a permission 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 tried every permutation that I can think of to make it work. I read, and this may be due to the way the docker-machine handles permissions with OSX, but the documentation for the dock says it mounts the /Users folder, so this should not be a problem.

Here 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 cannot help but think that it is really simple. Any help would be 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 for the container, it will not work with the installed volume. Without mount -v this is:

  • Container - drwxr-xr-x 4 mysql mysql 4096 Dec 24 00:37 mysql
+6
source share
2 answers

The problem is that these are the users used by Mac and Linux respectively. Mac does not like Linux, wanting to use 1 for user ID.

As I worked with all the permissions madness in my mac + docker-machine setup, this 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 a simple MySQL image 5.6.

The last two lines are necessary because changing the user ID for the mysql user will ruin the assembly of permissions for this image. => you need 777 permissions to run it here: /

I know this is a bit hacked, but so far the best solution I know for resolution is here.

+11
source

Try using the latest docker for mac instead of docker tools. Docker for Mac no longer uses VirtualBox, but rather HyperKit, a lightweight OS X virtualization solution built on top of Hypervisor.framework on OS X 10.10 Yosemite and higher.

I also suggest removing docker tools completely (they can coexist): https://github.com/docker/toolbox/blob/master/osx/uninstall.sh

With docker for mac, you don’t need to use permission hacks, it will work the same as in the linux build.

0
source

All Articles