Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker: MariaDB / MySQL startup fails on windows host

I am trying to use official mariadb docker image along with the php-fpm and nginx to run my Symfony 2 app.

The idea is to keep all the db files on a mounted folder. While on Mac OS it works just fine - on the Windows machine I am getting an error every time MariaDB attempts to start. The weird part is that it's actually able to create some files - I can see the ibdata1 file but the size of it is 0 bytes. There are also two aria_log files with few KBs of data which means that mysql is actually able to write there.

  • I'm using docker for windows 1.12.2 beta. But tried the stable one too.
  • The windows disk I'm storing my project on is shared (through the "Shared drives" section of the Docker for Windows UI)
  • The dir is 100% writeable since nginx and even mysql itself are able to put their logs in there
  • I'm totally not "out of disk space" as logs suggest

Here is my docker-compose file:

version: '2'
services:
db:
    image: mariadb
    ports:
        - "3306:3306"
    environment:
        MYSQL_ROOT_PASSWORD: root
        MYSQL_DATABASE: test
        MYSQL_USER: root
        MYSQL_PASSWORD: root
    volumes:
        - ./docker-runtime/mysql:/var/lib/mysql
php:
    build: ./docker/php-fpm
    volumes:
        - ./:/var/www/symfony
        - ./docker-runtime/logs/symfony:/var/www/symfony/app/logs
    links:
        - db
nginx:
    build: ./docker/nginx
    ports:
        - "80:80"
    links:
        - php
    volumes_from:
        - php
    volumes:
        - ./docker-runtime/logs/nginx/:/var/log/nginx

And here is what the log say when I do docker-compose up:

db_1     | 2016-10-18 13:14:06 7f79eed7f7c0 InnoDB: Error: Write to file ./ibdata1 failed at offset 0.
db_1     | InnoDB: 1048576 bytes should have been written, only 0 were written.
db_1     | InnoDB: Operating system error number 22.
db_1     | InnoDB: Check that your OS and file system support files of this size.
db_1     | InnoDB: Check also that the disk is not full or a disk quota exceeded.
db_1     | InnoDB: Error number 22 means 'Invalid argument'.
db_1     | InnoDB: Some operating system error numbers are described at
db_1     | InnoDB: http://dev.mysql.com/doc/refman/5.6/en/operating-system-error-codes.html
db_1     | 2016-10-18 13:14:06 140161674901440 [ERROR] InnoDB: Error in creating ./ibdata1: probably out of disk space
db_1     | 2016-10-18 13:14:06 140161674901440 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
db_1     | 2016-10-18 13:14:06 140161674901440 [ERROR] Plugin 'InnoDB' init function returned error.
db_1     | 2016-10-18 13:14:06 140161674901440 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
db_1     | 2016-10-18 13:14:06 140161674901440 [ERROR] Unknown/unsupported storage engine: InnoDB
db_1     | 2016-10-18 13:14:06 140161674901440 [ERROR] Aborting

I would really appreciate any ideas on this issue as I'm currently at the point of pulling my hair out

like image 675
Stas Parshin Avatar asked Oct 18 '16 13:10

Stas Parshin


2 Answers

Probably you have a permission problem. To discard change your docker-compose.yml to use named volumes:

version: '2'
services:
db:
    image: mariadb
    ports:
        - "3306:3306"
    environment:
        MYSQL_ROOT_PASSWORD: root
        MYSQL_DATABASE: test
        MYSQL_USER: root
        MYSQL_PASSWORD: root
    volumes:
        - mysql:/var/lib/mysql
php:
    build: ./docker/php-fpm
    volumes:
        - ./:/var/www/symfony
        - ./docker-runtime/logs/symfony:/var/www/symfony/app/logs
    links:
        - db
nginx:
    build: ./docker/nginx
    ports:
        - "80:80"
    links:
        - php
    volumes_from:
        - php
    volumes:
        - ./docker-runtime/logs/nginx/:/var/log/nginx
volumes:
  mysql:

Try and see if the mysql error goes away.

Regards

like image 89
Carlos Rafael Ramirez Avatar answered Nov 05 '22 05:11

Carlos Rafael Ramirez


You need to add this option when starting MariaDB (in Dockerfile's CMD or docker-compose command:):

--innodb-flush-method=fsync

It's documented here: https://github.com/docker-library/mariadb/issues/95

If it does not help, also add --innodb-use-native-aio=0.
Asynchronous I/O are not supported on Windows nor Mac OS X:
https://dev.mysql.com/doc/refman/8.0/en/innodb-linux-native-aio.html

like image 8
Sebien Avatar answered Nov 05 '22 04:11

Sebien