Docker Mysql 挂载数据卷后报错,无法启动,不知道是什么原因,无从下手,求教
系统 CentOS7.1810
docker-composer.yml 内容如下
version: '3'
services:
db:
image: mysql
container_name: test.mysql.01
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: '123123'
volumes:
- "/media/sf_code/docker/mysql/conf:/etc/mysql"
- "/media/sf_code/docker/mysql/data:/var/lib/mysql" ---- 挂载此行就无法启动,注释此行就正常
- "/media/sf_code/docker/mysql/files:/var/lib/mysql-files"
执行命令如下:
docker-compose up
报错信息如下:
Creating network "stack_default" with the default driver
Creating test.mysql.01 ... done
Attaching to test.mysql.01
test.mysql.01 | Initializing database
test.mysql.01 | mysqld: Can't create directory '/var/lib/mysql/' (OS errno 17 - File exists) -- 这里提示无法创建目录,什么鬼?
test.mysql.01 | 2019-08-01T12:08:28.936704Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.17) initializing of server in progress as process 28
test.mysql.01 | 2019-08-01T12:08:28.938479Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
test.mysql.01 | 2019-08-01T12:08:28.938503Z 0 [ERROR] [MY-010119] [Server] Aborting
test.mysql.01 | 2019-08-01T12:08:28.938900Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.17) MySQL Community Server - GPL. -- 镜像用的mysql:latest,下来的版本是8.0.17
test.mysql.01 exited with code 1
我把相同配置换成 MariaDB 就好了……
参考:https://github.com/docker-lib...