Permission denied when mounting Docker volume in OSX

greggilbert

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
Armin Braun

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

docker mounting volume with permission denied

GitLab CI/CD permission denied when mounting volume for docker

Docker mounting volume. Permission denied

How to solve permission denied when mounting volume during docker run command?

Docker: Got "permission denied" error at volume mounting directory

Docker rootfs_linux.go permission denied when mounting /proc

Docker compose permission denied with volume

Permission denied error when rebuilding docker image with volume

Permission Denied with mounting NFS with Webmin (Mac OSX + Ubuntu Setup)

Docker not starting, volume permission denied error

Chown permission denied while Docker volume binding

Permission denied error with docker-compose volume

when mounting volume, directory is empty in docker

Why does docker prompt "Permission denied" when backing up the data volume?

docker-compose issue: Permission denied when attempting to create/mount volume

Permission denied when python app tries to write log file into shared volume in docker

Permission denied when installing npm modules in OSX

Docker non mounting volume

mounting a docker volume to a docker container

Docker Compose Make Shared Volume Writable Permission Denied

Airflow on Docker: Can't Write to Volume (Permission Denied)

Unable to access jarfile error when mounting a volume in a Docker

Docker permission problems when doing volume mapping

Permission denied when running a container (docker 1.12.5)

Permission denied when writing logs in Docker

When mounting /var/run/docker.sock into a container, which file system is used for volume mounting?

Kubernetes docker volume mounting option

Docker container not mounting volume properly

Docker Volume not mounting any files