nfs 卷挂载到 ubuntu virtualbox 内的 mysql docker 容器失败

nfs volume mount to mysql docker container inside a ubuntu virtualbox fail

在我的评论中回答。无法回答我自己的问题。因此评论中的答案。 ------------------------*-------------------- ---

请帮助我解决我面临的 nfs 卷安装问题。

我有一个来自 freenas 服务器的 nfs 文件共享设置,我正在将其安装在主机上 linux(ubuntu 14.04 服务器)

mount -t nfs -o proto=tcp xxx.xxx.x.xxx:/mnt/freenas/nmedia /mnt/media

在 linux 主机上,我安装了 oracle virtualbox (4.3) 并且 linux virtualbox 与来自主机 /mnt/media 的共享文件夹 (ubuntu 14.04服务器),我在其中安装了 kodi-xbmc。在这个 virtualbox 上,我 docker 具有以下版本详细信息:

root@kodixbmc:~# docker version
Client version: 1.7.1
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 786b29d
OS/Arch (client): linux/amd64
Server version: 1.7.1
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 786b29d
OS/Arch (server): linux/amd64

我已经通过以下启动脚本将共享文件夹从主机安装到虚拟机中,并在 /etc/rc.local 中输入:

#!/bin/bash
echo 'Mounting Share folder to /mnt/Share'
`sudo mount -t vboxsf -o uid=$UID,gid=root media /mnt/media`

我想通过以下 运行 命令 运行 mysql 容器指向 /mnt/media/mysql

docker run -d --privileged --name=mysql -v /mnt/media/mysql/data:/var/lib/mysql -v /mnt/media/mysql/logs:/var/log/mysql mgmttools:443/phani/mysql:latest

Mysql 当我尝试通过

连接到终端时,恶魔没有启动
docker run -it --privileged --name=mysql -v /mnt/media/mysql/data:/var/lib/mysql -v /mnt/media/mysql/logs:/var/log/mysql mgmttools:443/phani/mysql:latest /bin/bash

然后自己执行mysqld using/usr/bin/mysqld_safe可以写入日志文件,下面是日志文件的内容

151006 11:02:19 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
151006 11:02:19 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
151006 11:02:19 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
151006 11:02:19 [Note] Plugin 'FEDERATED' is disabled.
/usr/sbin/mysqld: Table 'mysql.plugin' doesn't exist
151006 11:02:19 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
151006 11:02:19 InnoDB: The InnoDB memory heap is disabled
151006 11:02:19 InnoDB: Mutexes and rw_locks use GCC atomic builtins
151006 11:02:19 InnoDB: Compressed tables use zlib 1.2.8
151006 11:02:19 InnoDB: Using Linux native AIO
151006 11:02:19 InnoDB: Initializing buffer pool, size = 128.0M
151006 11:02:20 InnoDB: Completed initialization of buffer pool
151006 11:02:20  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'create'.
InnoDB: Cannot continue operation.
151006 11:02:20 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

任何卷挂载相关问题的经验法则是同步文件服务器用户和关键用户的用户和组 ID 运行 docker 容器中的进程。我可以通过将 mysql 用户的 uid 和 gid 以及我的 docker 容器的 mysql 组与我的 freenas 用户的 uid 和 gid 同步来解决我的问题。