我遇到运行docker-compose up
命令时退出的Mysql Docker问题。
这是我的docker-compose.yml
文件:
version: "2"
services:
web:
build: ./app
links:
- "db-mongo:db-mongo"
- "db-mysql:db-mysql"
ports:
- "443:3000"
volumes:
- "./app:/src"
- "/src/.sass-cache"
- "/src/node_modules"
- "/src/lib"
db-mongo:
build: ./mongo
ports:
- "27017:27017"
volumes:
- "./mongo/db:/data"
db-mysql:
image: mysql
ports:
- "3306:3306"
volumes:
- "./mysql/db:/var/lib/mysql"
- "./mysql/log:/var/log/mysql"
- "./mysql/conf.d:/etc/mysql/conf.d"
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: testt
文件夹./mysql/db
和./mysql/log
为空。
当我运行docker-compose up
时,输出:
db-mysql_1 | Initializing database
server_db-mysql_1 exited with code 1
当我运行docker ps -a
时:
0a5a7a643f18 mysql" docker-entrypoint.sh" 8分钟前退出(1)7分钟前server_db-mysql_1
奇怪的是,如果我运行docker run -d --name=new-mysql -p 3306:3306 -v /var/www/server/mysql/db:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=password mysql
它有效......
这里是docker logs 97c -f
的输出:
Initializing database
Database initialized
MySQL init process in progress...
Warning: Unable to load '/usr/share/zoneinfo/Factory' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/iso3166.tab' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/posix/Factory' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/right/Factory' as time zone. Skipping it.
Warning: Unable to load '/usr/share/zoneinfo/zone.tab' as time zone. Skipping it.
MySQL init process done. Ready for start up.
为什么我的docker-compose不能保持我的mysql docker?我必须遗漏一些东西......救命!谢谢
编辑:看来它是我的conf.d
文件夹出现了一些问题,因为当我删除卷- "./mysql/conf.d:/etc/mysql/conf.d"
时,server_db-mysql保持活动状态。
以下是mysql/conf.d/my.cnf
文件内容:
[mysqld]
general_log_file = /var/log/mysql/mysql.log
general_log = 1
为什么那个文件会崩溃mysql?
答案 0 :(得分:1)
在自定义配置文件中挂载{"source_ip": "123.123.123.1", "blacklist1": "Yes", "blacklist1": "worm"}
时出现权限问题。
请参阅此问题#docker-mysql-146以获取解决方案:
/var/log/mysql
目录的所有者和组必须与mysql一样。确保执行:
/var/log/mysql