nfs volume mount to mysql docker container inside

2019-09-12 05:43发布

问题:

Answered in my comment. Not able to answer my own question. Hence the answer in comment. -----------------------*------------------------

Please help me with the nfs volume mount issue I am facing.

I've a nfs file share set-up from freenas server, which I am mounting on a host linux (ubuntu 14.04 server)

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

On the linux host, I've oracle virtualbox (4.3) installed and I've linux virtualbox with shared folder from host /mnt/media (ubuntu 14.04 server again) in which I've installed kodi-xbmc. On this virtualbox, I've docker with following version details:

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

I've mounted the shared folder from host into the virtualbox through the following start-up script with entry in /etc/rc.local:

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

I wanted to run the mysql container pointing to the /mnt/media/mysql through the following run command:

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 demon is not starting, when I tried to connect to the terminal through

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

and then execute the mysqld myself using/usr/bin/mysqld_safe it is able to write into the log file and following is the content of the log file

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

回答1:

Thumb rule for any volume mount related issues is to synchronize user and group ids of the file server user and the key user running the processes in the docker container. I am able to solve my problem by synchronizing the uid and gid of the mysql user and mysql group of my docker container with that of my freenas user.