我尝试了很多次都没有成功,但结果无济于事。
我的设置是这样的:
我的代码、Dockerfile 和 Docker-compose 文件保存在共享文件夹 say (/vagrant/test) 中,因此我可以轻松地从 Windows 主机访问它们。
来自来宾 VM:(文件权限)
vagrant@dev-env-testing:/vagrant/test$ ll
drwxrwxrwx 1 vagrant vagrant 4096 Apr 19 12:33 ./
drwxr-xr-x 23 root root 4096 Apr 14 12:50 ../
drwxrwxrwx 1 vagrant vagrant 0 Apr 14 10:30 .vagrant/
-rwxrwxrwx 1 vagrant vagrant 1072 Apr 14 13:36 Vagrantfile*
-rwxrwxrwx 1 vagrant vagrant 0 Apr 19 11:23 a*
drwxrwxrwx 1 vagrant vagrant 0 Apr 19 12:33 code/
drwxrwxrwx 1 vagrant vagrant 4096 Apr 19 12:28 mysql-data/
-rwxrwxrwx 1 vagrant vagrant 0 Apr 19 12:29 mysqlcontainer_bug_sharefolder.txt*
我还在组中添加了用户“vagrant”:999(systemd-coredump)
vagrant@dev-env-testing:/vagrant$ id
uid=1000(vagrant) gid=1000(vagrant) groups=1000(vagrant),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),116(lxd),997(docker),999(systemd-coredump)
为了测试,我使用这个命令来创建一个容器:
docker run -d --name=test-mysql4 -e MYSQL_ROOT_PASSWORD=mypassword -p 6604:3306 -v /vagrant/mysql-data:/var/lib/mysql MySQL
在这里,我正在尝试为 mysql 容器创建一个持久卷(安装在主机共享文件夹 /vagrant/mysql-data
上),但容器创建失败。
场景 1:
<块引用>/vagrant/mysql-data:此文件夹中没有数据。
docker 日志 test-mysql4
2021-04-19 12:28:37+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.23-1debian10 started.
2021-04-19 12:28:37+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2021-04-19 12:28:37+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.23-1debian10 started.
2021-04-19 12:28:37+00:00 [Note] [Entrypoint]: Initializing database files
2021-04-19T12:28:37.465722Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.23) initializing of server in progress as process 43
2021-04-19T12:28:37.472616Z 0 [Warning] [MY-010159] [Server] Setting lower_case_table_names=2 because file system for /var/lib/mysql/ is case insensitive
2021-04-19T12:28:37.478227Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-04-19T12:28:41.252791Z 0 [ERROR] [MY-012592] [InnoDB] Operating system error number 95 in a file operation.
2021-04-19T12:28:41.252961Z 0 [ERROR] [MY-012596] [InnoDB] Error number 95 means 'Operation not supported'
2021-04-19T12:28:41.253274Z 0 [ERROR] [MY-012646] [InnoDB] File ./undo_001: 'Linux aio' returned OS error 195. Cannot continue operation
2021-04-19T12:28:41.253413Z 0 [ERROR] [MY-012981] [InnoDB] Cannot continue operation.
或者我收到这个错误
场景 2: /vagrant/mysql-data: 有以下文件,
/vagrant/mysql-data$ ls
'#ib_16384_0.dblwr' '#ib_16384_1.dblwr' ib_logfile1 ib_logfile101
ibdata1 undo_001 undo_002 undo_1_trunc.log undo_2_trunc.log
2021-04-19 12:25:20+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.23-1debian10 started.
2021-04-19 12:25:20+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2021-04-19 12:25:20+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.23-1debian10 started.
2021-04-19 12:25:20+00:00 [Note] [Entrypoint]: Initializing database files
2021-04-19T12:25:20.641591Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.23) initializing of server in progress as process 43
2021-04-19T12:25:20.645008Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2021-04-19T12:25:20.645019Z 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.
2021-04-19T12:25:20.645069Z 0 [ERROR] [MY-010119] [Server] Aborting
2021-04-19T12:25:20.645195Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.23) MySQL Community Server - GPL.
vagrant@rma-dev-env-testing:/vagrant/mysql-data$ ls
非常感谢任何帮助。
提前致谢