4

I'm attempting to create a MySQL database (on a Docker container, with docker toolbox on a Windows 10 host) using docker-compose with this configuration:

docker-compose.yml

version: '2'
services:
  db:
    container_name: test
    restart: unless-stopped
    image: mysql:5.7
    environment:
      MYSQL_ROOT_PASSWORD: 'password'
      MYSQL_DATABASE: 'mydb'
    ports: 
      - 6612:3306
    volumes:
      - ./db:/var/lib/mysql

I run this in a folder that only contains the docker-compose.yml and get the following output.

$ docker-compose up

Recreating test ... done
Attaching to test
test  | Initializing database
test  | 2018-04-21T17:31:30.722810Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
test  | 2018-04-21T17:31:30.727269Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
test  | 2018-04-21T17:31:30.727618Z 0 [ERROR] Aborting
test  |
test  | Initializing database
test  | 2018-04-21T17:31:30.722810Z 0 [Warning] TIMESTAMP with implicit 
      .
      .
      .

It seems to be complaining about files existing but how could there when the folder is empty?

Second time I run the same file, in the same empty (apart from docker-compose.yml) I get:

Starting test ... done
Attaching to test
test  | Initializing database
test  | 2018-04-21T17:36:12.716214Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
test  | 2018-04-21T17:36:12.726611Z 0 [Warning] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
test  | 2018-04-21T17:36:13.466867Z 0 [ERROR] InnoDB: Operating system error number 22 in a file operation.
test  | 2018-04-21T17:36:13.467174Z 0 [ERROR] InnoDB: Error number 22 means 'Invalid argument'
test  | 2018-04-21T17:36:13.467475Z 0 [ERROR] InnoDB: File ./ib_logfile101: 'aio write' returned OS error 122. Cannot continue operation
test  | 2018-04-21T17:36:13.467649Z 0 [ERROR] InnoDB: Cannot continue operation.
test exited with code 1

This time it creates the a ./db folder in my pwd with a few files:

  • ib_logfile1
  • ib_logfile101
  • ibdata1

But nothing more, and running it again we are back to the first output. The same docker-compose.yml works without a hitch on Ubuntu 16.04. Could anyone advise me what might be wrong?

Christian Eriksson
  • 2,038
  • 2
  • 22
  • 28

1 Answers1

1

It seems the key was in in this output line:

[ERROR] InnoDB: File ./ib_logfile101: 'aio write' returned OS error 122.

Apparently having AIO enabled doesn't work with my set up. I'm still not sure why but this revised docker-compose.yml works for me:

version: '2'
services:
  db:
    container_name: test
    restart: unless-stopped
    image: mysql:5.7
    command: --innodb_use_native_aio=0
    environment:
      MYSQL_ROOT_PASSWORD: 'password'
      MYSQL_DATABASE: 'mydb'
    ports: 
      - 6612:3306
    volumes:
      - ./db:/var/lib/mysql

Found this thanks to AndrewD's answer still not sure what exactly is the problem. Though I suspect Docker Toolbox (as opposed to Docker for Windows) might have something to do with it.

Christian Eriksson
  • 2,038
  • 2
  • 22
  • 28
  • It does not work for me, but I have the error `File ./ibdata1: 'open' returned OS error 71.` – nowox Dec 07 '18 at 13:20