I have a problem with Mysql Docker which exits when I run my docker-compose up
command.
Here is my docker-compose.yml
file :
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
Folders ./mysql/db
and ./mysql/log
are empty.
When I run docker-compose up
, here the output :
db-mysql_1 | Initializing database
server_db-mysql_1 exited with code 1
When I run docker ps -a
:
0a5a7a643f18 mysql "docker-entrypoint.sh" 8 minutes ago Exited (1) 7 minutes ago server_db-mysql_1
The strange thing is if I run docker run -d --name=new-mysql -p 3306:3306 -v /var/www/server/mysql/db:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=password mysql
it works...
And here the output of 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.
Why does my docker-compose can't keep alive my mysql docker ? I must missing something... Help ! Thanks
EDIT : It appears it is my conf.d
folder which is making some problems, because when I remove volume - "./mysql/conf.d:/etc/mysql/conf.d"
, server_db-mysql keeps alive.
Here is the mysql/conf.d/my.cnf
file content :
[mysqld]
general_log_file = /var/log/mysql/mysql.log
general_log = 1
Why does that file is crashing the mysql ?
It's a permission issue when mounting /var/log/mysql
in your custom config file.
Please reference this issue #docker-mysql-146 for the solution:
The owner and group of the /var/log/mysql
directory has to be as expected by mysql. Ensure that, execute:
docker exec mysql chown mysql:root /var/log/mysql
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With