我是在MacOS下用Docker Toolbox,部署mysql,并且挂载了一个volume到/var/lib/mysql,但是启动容器的时候,报错。感觉和volume的权限相关。
具体错误展现如下:
问题原因:
这是比较完整的解答,观点比较正确,供你参考吧
@mikeys Boot2Docker creates a VirtualBox share of /Users on your Mac to /Users on the Linux host. This is what lets you share any folder under your Mac's /Users directory with a docker container, because the paths are the same.
Really what it does is automatically mount a VirtualBox share named Users to /Users (under Linux), and it so happens that it creates a share called Users from your Mac's /Users.
The problem is that these shares are owned by the docker user (uid 1000) on in the Linux host. This means that any container that needs to write to a shared folder on your Mac will need to run its process as UID 1000.
This is only a problem with Boot2Docker because it uses the virtual box sharing, which changes the uid of the share to the docker user and you can't change this easily from Linux.
In Vagrant, I usually solved this by changing my Vagrant file to use different permissions for the virtual box share:
config.vm.synced_folder ".", "/vagrant", :mount_options => ['dmode=777,fmode=666']
Maybe you could do something like that inside of your Boot2Docker image, I haven't looked into it. I think you would make these changes to /etc/rc.d/automount-shares in the Linux VM
One way I solved this was to just set my containers up so that I could configure them with the UID I wanted them to run their processes as, so I could just set it to 1000. The downside to this is that you basically need to create your own images for everything since most containers I've found don't let you do this.
I hope this helps.
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。