我尝试使用Docker Machine创建本地开发设置。我在尝试创建一个mysql容器时一直遇到错误。这是我的设置。
docker-machine version 0.3.0
Virtualbox版本4.3.30
虚拟机中的默认boot2docker vm,共享文件夹/用户
我创建了要在/Users/tinnguyen/Development/Docker/containers/mysql
创建容器时挂载的mysql文件夹
标准许可:
drwxr-xr-x 2 tinnguyen staff 68 Jul 25 16:45 mysql
下面是我的docker命令
docker run --name mysql5.6 --privileged=true -p 3306:3306 -v /Users/jice_mac/opt/docker/mysql/mysql5.6/datadir:/var/lib/mysql -v /Users/jice_mac/opt/docker/mysql/mysql5.6/conf.d:/etc/mysql/conf.d -v /Users/jice_mac/opt/docker/mysql/mysql5.6/logs:/logs -e MYSQL_ROOT_PASSWORD=123456 -e TZ=Asia/Shanghai -d mysql:5.6
当我docker logs mysql 时,这就是我得到的错误
jice-mac:~ jice$ docker logs 1855fc0379d8
2019-11-07 00:21:53+08:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.6.46-1debian9 started.
2019-11-07 00:21:53+08:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2019-11-07 00:21:53+08:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 5.6.46-1debian9 started.
2019-11-07 00:21:53+08:00 [Note] [Entrypoint]: Initializing database files
2019-11-07 00:21:53 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-11-07 00:21:53 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2019-11-07 00:21:53 0 [Note] /usr/sbin/mysqld (mysqld 5.6.46) starting as process 48 ...
2019-11-07 00:21:53 48 [Warning] Can't create test file /var/lib/mysql/1855fc0379d8.lower-test
2019-11-07 00:21:53 48 [Warning] Can't create test file /var/lib/mysql/1855fc0379d8.lower-test
2019-11-07 00:21:53 48 [Note] InnoDB: Using atomics to ref count buffer pool pages
2019-11-07 00:21:53 48 [Note] InnoDB: The InnoDB memory heap is disabled
2019-11-07 00:21:53 48 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2019-11-07 00:21:53 48 [Note] InnoDB: Memory barrier is not used
2019-11-07 00:21:53 48 [Note] InnoDB: Compressed tables use zlib 1.2.11
2019-11-07 00:21:53 48 [Note] InnoDB: Using Linux native AIO
2019-11-07 00:21:53 48 [Note] InnoDB: Using CPU crc32 instructions
2019-11-07 00:21:53 48 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2019-11-07 00:21:53 48 [Note] InnoDB: Completed initialization of buffer pool
2019-11-07 00:21:53 7f7ec84a2040 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
2019-11-07 00:21:53 7f7ec84a2040 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
2019-11-07 00:21:53 48 [ERROR] InnoDB: Creating or opening ./ibdata1 failed!
2019-11-07 00:21:53 48 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
2019-11-07 00:21:53 48 [ERROR] Plugin 'InnoDB' init function returned error.
2019-11-07 00:21:53 48 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2019-11-07 00:21:53 48 [ERROR] Unknown/unsupported storage engine: InnoDB
2019-11-07 00:21:53 48 [ERROR] Aborting
网上普遍答案是"默认情况下,它应该正确设置并运行,但您可能需要检查VirtualBox上的文件夹共享设置。
运行VirtualBox,检查默认机器设置。单击“共享文件夹”并验证主机macbook中的/Users文件夹是否已安装在VM中。",其实就是共享目录权限问题,可以尝试把共享目录改为自己新创建的文件夹就可以了,因为默认的/User文件夹对当前用户没有相应权限(例如我将/Users 替换为/Users/jice_mac/opt就可以了)
http://dockone.io/article/481
https://www.thinbug.com/q/31631541 |