Skip to content

Instantly share code, notes, and snippets.

@vhugo
Last active February 27, 2016 01:42
Show Gist options
  • Save vhugo/01b0dd227c08e687e0cf to your computer and use it in GitHub Desktop.
Save vhugo/01b0dd227c08e687e0cf to your computer and use it in GitHub Desktop.
Fix issue with MySQL Docker when adding local data volume on Mac OX. (docker-machine/vbox)

When trying to add a volume to a container for a MySQL Docker on Mac OSX, I had permission issues to create the database files. I create a new image based on the MySQL Docker image to fix the issue before running the server. Got the idea from this comment and this other one

Using this thing

  • download Dockerfile and docker-permfix.sh
  • in you Terminal, go to the directory you have these files and run docker build -t your_user/mysql .
  • then to create your container, run this:
docker run -d --name mysql-5.5.44 -p 3306:3306 -e MYSQL_ROOT_PASSWORD=somepassword4R00T \
	-v /Users/your_user/data/mysql:/var/lib/mysql your_user/mysql

If you already have data, you might not need -e MYSQL_ROOT_PASSWORD=somepassword4R00T as part of the command.

FROM mysql:5.5.44
VOLUME /var/lib/mysql
RUN usermod -u 1000 mysql
CMD ["/entrypoint.sh", "mysqld", "--user=mysql", "--datadir=/var/lib/mysql"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment