在Ubuntu中通过docker-compose部署MySQL时无法部署;docker-compose.yml文件如下: version: '3' services: mysql: restart: always image: mysql:8.2 network_mode: bridge container_name: mysql environment: MYSQL_ROOT_PASSWORD: root123 command: --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci --explicit_defaults_for_timestamp=true --lower_case_table_names=1 --max_allowed_packet=128M volumes: - /etc/localtime:/etc/localtime:ro - /data/docker/mysql/mysql:/var/lib/mysql - /data/docker/mysql/etc:/etc/mysql:ro ports: - 3306:3306 我的步骤如下: 1.注释挂载,直接启动mysql 成功 2.复制容器中的/var/lib/mysql到宿主机我希望挂载的地方 3.复制/etc/mysql ,然后编写my.cnf放到宿主机/data/docker/mysql/etc/mysql/conf.d下 4.删除镜像 5.打开注释 错误如下: 2024-01-21 12:00:35+08:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.2.0-1.el8 started. 2024-01-21 12:00:35+08:00 [ERROR] [Entrypoint]: mysqld failed while attempting to check config command was: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci --explicit_defaults_for_timestamp=true --lower_case_table_names=1 --max_allowed_packet=128M --verbose --help --log-bin-index=/tmp/tmp.5xbHMoySK8 mysqld: Can't read dir of '/etc/mysql/conf.d/' (OS errno 2 - No such file or directory) mysqld: [ERROR] Stopped processing the 'includedir' directive in file /etc/my.cnf at line 36. mysqld: [ERROR] Fatal error in defaults handling. Program aborted!