描述一下问题经过:
使用docker compose 部署mysql5.7
文件如下: 使用命名卷的情况下,匿名卷不存在该问题
services:mysql:restart: alwaysimage: mysql:5.7container_name: mysql-devports:- 3306:3306environment:- MYSQL_DATABASE=dev- MYSQL_ROOT_PASSWORD=123456- TZ=Asia/Shanghaicommand:- mysqld- --character-set-server=utf8mb4- --collation-server=utf8mb4_unicode_cihealthcheck:test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "--silent"]interval: 3sretries: 5volumes:- mysqlVolume:/var/log/mysql- mysqlVolume:/etc/mysql/conf.d- mysqlVolume:/etc/mysql/mysql.conf.d- mysqlVolume:/var/lib/mysql
volumes:mysqlVolume:
出现:显示status为restarting
查看日志:docker logs 容器
发现如下错误:
TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2024-05-04T09:03:39.284335Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2024-05-04T09:03:39.284370Z 0 [ERROR] Aborting
问题解决:
docker volume ls
找到我们的命名卷我的卷 对应文件的则是 composeinfo_mysqlVolume(看样子使用文件名称拼接卷名称建立的)
docker inspect composeinfo_mysqlVolume
找到:
cd 进入该目录:
发现有一个错误文件:rm -rf error.log
docker restart 容器即可