Bug #104923 Cannot mount MySql data directory in Docker for Windows
Submitted: 13 Sep 2021 8:19 Modified: 26 Apr 2022 12:46
Reporter: AntCDL Waters Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S2 (Serious)
Version:MySql server 8.0.26, 8.0.28 OS:Windows (Windows 10 Enterprise 1909)
Assigned to: CPU Architecture:Any
Tags: docker, innodb, MySQL, windows

[13 Sep 2021 8:19] AntCDL Waters
Description:
When you use MySql in a container you need to mount the Data folder, so the databases can be used either in the container, or directly on the host machine.
This fails on Docker for Windows, with the error:

[ERROR] [MY-012271] [InnoDB] The innodb_system data file 'ibdata1' must be writable

This issue is documented for mariadb in the following link, but the solutions there do not work for me with MySql:

https://github.com/MariaDB/mariadb-docker/issues/95

How to repeat:
To reproduce:
1) Try to create the Docker container using the following "docker-compose.yml"

version: '3.2'
services:
  db:
    image: mysql/mysql-server:8.0
    command: 
        --datadir=/tmp/MySqlData
        --default-authentication-plugin=mysql_native_password
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: <password>
    volumes:
      - ./read_only_mysql_config.cnf:/etc/mysql/my.cnf:ro
      - c:\ProgramData\MySQL\MySQL Server 8.0\Data:/tmp/MySqlData

2) The Docker log reports the following:

2021-09-13T07:40:56.119674Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.26) starting as process 1
2021-09-13T07:40:56.126774Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /tmp/MySqlData/ is case insensitive
2021-09-13T07:40:56.150167Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-09-13T07:40:56.152637Z 1 [ERROR] [MY-012271] [InnoDB] The innodb_system data file 'ibdata1' must be writable
2021-09-13T07:40:56.152740Z 1 [ERROR] [MY-012278] [InnoDB] The innodb_system data file 'ibdata1' must be writable
2021-09-13T07:40:56.152798Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2021-09-13T07:40:56.153059Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2021-09-13T07:40:56.153189Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-09-13T07:40:56.154146Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.26)  MySQL Community Server - GPL.
[26 Apr 2022 12:46] MySQL Verification Team
Hello,

Thank you for the bug report.
Verified as described.

Regards,
Ashwini Patil
[26 Apr 2022 12:50] MySQL Verification Team
8.0.28 test results

Attachment: 104923_test_results.png (image/png, text), 204.80 KiB.