我嘗試使用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就可以了)