如何在Windows 10上设置docker-compose来初始化MySQL数据库?

时间:2018-04-21 18:21:00

标签: mysql docker docker-compose

我尝试使用此配置的docker-compose创建一个MySQL数据库(在Docker容器上,在Windows 10主机上使用docker工具箱):

搬运工-compose.yml

atomic

我在仅包含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 的文件夹中运行此命令并获得以下输出。

docker-compose.yml

似乎抱怨文件存在,但文件夹为空时怎么办?

我第二次运行相同的文件,同样为空(除了$ 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 . . . )我得到:

docker-compose.yml

这次它在我的pwd中创建了一个带有几个文件的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 文件夹:

  • ib_logfile1
  • ib_logfile101
  • ibdata1中

但仅此而已,再次运行它我们又回到了第一个输出。同样的./db在Ubuntu 16.04上顺利运行。任何人都可以告诉我可能有什么问题吗?

1 个答案:

答案 0 :(得分:0)

似乎关键在于此输出行:

docker-compose.yml

显然已启用AIO并不能解决我的设置问题。我还不确定为什么,但这个修订后的[ERROR] InnoDB: File ./ib_logfile101: 'aio write' returned OS error 122. 对我有用:

docker-compose.yml

感谢AndrewD&{39}仍然不确定究竟是什么问题。虽然我怀疑Docker Toolbox(而不是Docker for Windows)可能与它有关。