I am struggling with the proper use of docker-compose (for a local dev environment), when I include a data volume to a host directory mariadb (and mysql) fails. How do I use a host folder with docker-compose and with the correct permissions. I see several other data volume questions, but in this case the host folder is mounted and mariadb is not able to use it.
In my docker-compose.yml I have:
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
But something is off:
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.
Im not sure its permissions given that the mysql dir is written in the host holder. Im also on a mac with kitematic:
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