环境
使用的环境是Windows10+homestead(VirtualBox)
启动过程
运行sudo docker-compose up -d
容器可以正常启动
运行sudo docker exec -it db-mysql bash
进入mysql
容器操作数据库报错:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
运行service mysql status
查看mysql
启动状态,发现服务未启动
运行sudo docker logs db-mysql
查看容器启动日志:
[ERROR] InnoDB: Operating system error number 95 in a file operation.
[ERROR] InnoDB: Error number 95 means 'Operation not supported'
[Note] InnoDB: Some operating system error numbers are described at http://dev.mysql.com/doc/refman/5.7/en/operating-system-error-codes.html
[ERROR] InnoDB: File ./ib_logfile0: 'Linux aio' returned OS error 195. Cannot continue operation
[ERROR] InnoDB: Cannot continue operation.
解决办法
start the container like this :
docker run -it mysql --innodb_use_native_aio=0
add the command to your docker-compose file :
command: --innodb_use_native_aio=0
add an option to your my.cnf file in your build
innodb_use_native_aio=0
From stackoverflow By @AndrewD
附:我的docker-compose.yml
文件
version: "2"
services:
mysql:
image: docker-mysql57
container_name: db-mysql
restart: always
environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_DATABASE=${MYSQL_DATABASE}
- MYSQL_USER=${MYSQL_USER}
- MYSQL_PASSWORD=${MYSQL_PASSWORD}
volumes:
- ./data/mysql:/var/lib/mysql
ports:
- 33066:3306
command: --innodb_use_native_aio=0
喜欢这篇文章的话 打赏一下吧!