数据库无法启动 - 主机目录作为数据卷

时间:2015-06-03 15:17:02

标签: database docker

我正在努力正确使用docker-compose(对于本地开发环境),当我将数据卷包含到主机目录时,mariadb(和mysql)失败。如何使用具有docker-compose且具有正确权限的主机文件夹。我看到其他几个数据卷问题,但在这种情况下,主机文件夹已挂载,并且mariadb无法使用它。

在我的docker-compose.yml中,我有:

expressionengine:
  image: mariadb
  expose: 
   - "3306"
  volumes: # /var/lib/mysql is the datadir from my.cnf
   - ../containers/expressionengine/var-lib-mysql/:/var/lib/mysql
  environment:
   - MYSQL_ROOT_PASSWORD=password
   - MYSQL_DATABASE=expressionengine

但有些事情已经结束:

Attaching to builddev_expressionengine_1
expressionengine_1 | Running mysql_install_db ...
expressionengine_1 | Installing MariaDB/MySQL system tables in '/var/lib/mysql/' ...
expressionengine_1 | 150603  5:15:20 [Note] /usr/sbin/mysqld (mysqld 10.0.19-MariaDB-1~wheezy-log) starting as process 38 ...
expressionengine_1 | 150603  5:15:20 [Note] InnoDB: Using mutexes to ref count buffer pool pages
expressionengine_1 | 150603  5:15:20 [Note] InnoDB: The InnoDB memory heap is disabled
expressionengine_1 | 150603  5:15:20 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
expressionengine_1 | 150603  5:15:20 [Note] InnoDB: Memory barrier is not used
expressionengine_1 | 150603  5:15:20 [Note] InnoDB: Compressed tables use zlib 1.2.7
expressionengine_1 | 150603  5:15:20 [Note] InnoDB: Using Linux native AIO
expressionengine_1 | 150603  5:15:20 [Note] InnoDB: Not using CPU crc32 instructions
expressionengine_1 | 150603  5:15:20 [Note] InnoDB: Initializing buffer pool, size = 256.0M
expressionengine_1 | 150603  5:15:20 [Note] InnoDB: Completed initialization of buffer pool
expressionengine_1 | 2015-06-03 05:15:20 7f2425ed9760  InnoDB: Operating system error number 13 in a file operation.
expressionengine_1 | InnoDB: The error means mysqld does not have the access rights to
expressionengine_1 | InnoDB: the directory.

我不确定它的权限,因为mysql目录是在主机持有者中编写的。我也在使用kitematic的Mac上:

bash-3.2$ cd containers/expressionengine/var-lib-mysql/
bash-3.2$ ls -la
total 0
drwxr-xr-x  3 tom  staff  102 Jun  3 10:16 .
drwxr-xr-x  3 tom  staff  102 Jun  3 10:16 ..
drwxr-xr-x  2 tom  staff   68 Jun  3 10:16 mysql

2 个答案:

答案 0 :(得分:1)

权限错误。

要修复它,只需运行类似:

docker -v $(pwd)/containers/expressionengine/var-lib-mysql/:/var/lib/mysql mariadb chown -R mysql /var/lib/mysql

假设mysql是正确的用户,并且您当前位于containers文件夹下的目录中。

将来,您可能会发现使用data container更容易。

答案 1 :(得分:0)

该问题仅存在于OSX上,与boot2docker如何使用vboxsf有关。 vboxsf安装有一个UID,但数据库服务需要另一个。相关主题:https://github.com/kitematic/kitematic/issues/593