Tags: Docker, mysql, file permssion
I am recently moving away from Azure Mysql server to a local mysql server on VM.
To protect from data losing, I store mysql files on my VM and use -v to mount it to docker container.
[bash]
docker run \
--name mysql \
--network wp-net \
--network-alias mysql-host \
-v $PWD/mysql:/var/lib/mysql
-e MYSQL_ROOT_PASSWORD=root \
mysql:5.7.22
[/bash]
I would like to add all this files to git repo so that I can push them to remote regularly. But when I tried to do git init, permission is denied.
The mysql files are created by mysql container, and the user and group are both mysql. But when I view the files from the host machine. both user and mysql are 999.
To resolve this issue, I changed the files' group to my host user's group.
[bash]
chown -R 999:fennng mysql
[/bash]
Then I updated the files permissions so that the host user can access it.
Within the mysql folder, run
[bash]
sudo find . -type d -exec chmod 775 {} \;
sudo find . -type f -exec chmod 664 {} \;
[/bash]
Now both 999 and user's in fennng group can access these files.
It's not a great solution, but it's much safer than setting everything to 777.
没有评论:
发表评论