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
- download
Dockerfile
anddocker-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.