【发布时间】:2018-04-21 18:21:00
【问题描述】:
我正在尝试使用具有此配置的 docker-compose 创建 MySQL 数据库(在 Docker 容器上,在 Windows 10 主机上使用 docker 工具箱):
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
我在一个仅包含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 除外)我得到:
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
这次它在我的密码中创建了一个 ./db 文件夹,其中包含一些文件:
- ib_logfile1
- ib_logfile101
- ibdata1
但仅此而已,再次运行它,我们又回到了第一个输出。相同的 docker-compose.yml 在 Ubuntu 16.04 上运行顺利。谁能告诉我可能出了什么问题?
【问题讨论】:
标签: mysql docker docker-compose