Docker Mysql 挂载 /var/lib/mysql 后无法启动

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
阅读 19.7k
2 个回答
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏