Hello,
Here is what I get when I try to run :
docker run -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=dbname -d -v /path/to/vol:/var/lib/mysql -p 32775:3306 mysql
Initializing database
2018-02-10T23:43:26.434351Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-02-10T23:43:26.438783Z 0 [Warning] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2018-02-10T23:43:27.727838Z 0 [ERROR] InnoDB: Operating system error number 22 in a file operation.
2018-02-10T23:43:27.728063Z 0 [ERROR] InnoDB: Error number 22 means 'Invalid argument'
2018-02-10T23:43:27.728141Z 0 [ERROR] InnoDB: File ./ib_logfile101: 'aio write' returned OS error 122. Cannot continue operation
The only workaround I found was to build an other image from mysql with this dockerfile :
FROM mysql
RUN usermod -u 1000 mysql && echo "innodb_use_native_aio=0" >> /etc/mysql/conf.d/docker.cnf
But I'd like to be able to directly launch a mysql container from command line.
Is there a solution/workaround to this problem?
[EDIT] : It looks like the problem occurs when I try to mount a directory that is shared with the OSX host from my docker-machine as a volume.
Yeah, we often see failure when using databases on VM/Host shared file systems.
You can specify the user id via --user to docker (https://github.com/docker-library/mysql/pull/161) and you can pass almost any my.cnf value as a flag to the container.
$ docker run --user 1000:50 -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=dbname -d -v /path/to/vol:/var/lib/mysql -p 32775:3306 mysql --innodb-use-native-aio=0
You could also just use a named volume and not have to worry about filesystem compatibility issues.
It seems to work!
I actually wasn't aware that you coult pass custom uid:gid with --user.
Thank you for this anwer!
Most helpful comment
Yeah, we often see failure when using databases on VM/Host shared file systems.
You can specify the user id via
--userto docker (https://github.com/docker-library/mysql/pull/161) and you can pass almost anymy.cnfvalue as a flag to the container.You could also just use a named volume and not have to worry about filesystem compatibility issues.