开发者社区> 问答> 正文

在MacOS+Toolbox下部署mysql并且成功挂载volume?

我是在MacOS下用Docker Toolbox,部署mysql,并且挂载了一个volume到/var/lib/mysql,但是启动容器的时候,报错。感觉和volume的权限相关。
具体错误展现如下:
999

展开
收起
蛮大人123 2016-02-12 14:40:24 3014 0
1 条回答
写回答
取消 提交回答
  • 我说我不帅他们就打我,还说我虚伪

    问题原因:
    这是比较完整的解答,观点比较正确,供你参考吧
    @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.

    2019-07-17 18:41:21
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
搭建电商项目架构连接MySQL 立即下载
搭建4层电商项目架构,实战连接MySQL 立即下载
PolarDB MySQL引擎重磅功能及产品能力盛大发布 立即下载