-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
5.7.10-fails to mount volume /var/log/mysql
#146
Comments
Probably need to chown or chmod the |
@yosifkit Thanks for your reply. |
Anything from docker logs ? |
@ltangvald |
You can run |
Still seems like a permission issue. I used your exact config and these are the steps I tried: $ docker run -it --rm -v ~/dicker/tmp/my.cnf:/etc/mysql/conf.d/custom.cnf -v ~/dicker/tmp/mysql-logs/:/var/log/mysql/ --name mysql -e MYSQL_ROOT_PASSWORD=12345 mysql bash
root@1c384a908efa:/# /entrypoint.sh mysqld # try default command
Initializing database
root@1c384a908efa:/# mysqld --initialize # try to just init the database, no output :(
root@1c384a908efa:/# ls -al /var/lib/mysql/ # check contents of the directories
total 8
drwxr-xr-x 2 mysql mysql 4096 Mar 22 20:14 .
drwxr-xr-x 14 root root 4096 Mar 17 22:24 ..
root@1c384a908efa:/# ls -al /var/log/mysql/
total 8
drwxr-sr-x 2 root 1000 4096 Mar 22 20:14 .
drwxr-xr-x 5 root root 4096 Mar 17 22:24 ..
root@1c384a908efa:/# exit
$ # ok, lets do a new container to be safe
$ docker run -it --rm -v ~/dicker/tmp/my.cnf:/etc/mysql/conf.d/my.cnf -v ~/dicker/tmp/mysql-logs/:/var/log/mysql/ --name mysql -e MYSQL_ROOT_PASSWORD=12345 mysql bash
root@d27a8e03f5db:/# ls -al /var/log/mysql/ # still empty and owned by root and my group
total 8
drwxr-sr-x 2 root 1000 4096 Mar 22 19:52 .
drwxr-xr-x 5 root root 4096 Mar 17 22:24 ..
root@d27a8e03f5db:/# chown mysql:mysql /var/log/mysql/
root@d27a8e03f5db:/# /entrypoint.sh mysqld
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.
/entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
MySQL init process done. Ready for start up.
$ # looks like it is ready!
$ # from other terminal, let's test mysql client
$ docker exec -it mysql bash
root@d27a8e03f5db:/# mysql -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.11-log MySQL Community Server (GPL)
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select 1;
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)
mysql> The mount point will be owned by root or whoever created the folder on the host. You should be able to just do |
@yosifkit Thanks a lot. |
The entrypoint script ensures the correct permission to datadir. Maybe we need to do something similar for logdir? |
@ltangvald can we use the same |
Yeah, I think we can do it in the same way, though I haven't tested it. |
@yosifkit hi, please help to fix this issue as there are many users meet it on SO. thanks a lot. |
hi, I also meet this issue when I want persist
|
Hi, I solved this issue by using the following command:
|
By executing chown 999:999 solved the problem. |
Closing solved issue! |
Still not working here. The docker image provides absolutely zero information about what's going wrong (it just exits with status 1), and there are no logs in Docker other than |
@zaneclaes, The problem discussed in this issue is caused by user-supplied config to MySQL for logging to some directory and yet not giving the I alluded to using |
In Docker without mount, I had to make the folders and touch the log files in the folder I want to use:
After performing a
|
Still can't get it to work. |
Can you provide your Dockerfile and the errors? |
I just realized that your instructions were for without using a mount, and if I remove the mount, this does work. However, I still get access is denied when using a mount.
|
I see that you are mounting the volumes so your local files are overwritten and mapped with your container. However, you have a permission issue to write and/or read on that file. You could also try to use the below command in your CMD or Entrypoint: chown -R mysql:mysql /var/log/mysql This way, before starting mysql, you are setting the permissions for the folder you are mapping |
But why would I have to do that? Why is this so hard? Just to be able to have log files written to a folder that is accessible from the host? Also, why would I have to chown that folder from the Entrypoint, when I'm doing it from the dockerfile? |
@laurin1 Apparently after mouting, your container does not have the permission to edit the file. So you need to update the permissions of that file. The volumes are ALWAYS mapped after your Docker build. That's why, chown in your Dockerfile doesn't have any effect if you mount that folder afterwards. |
In oder to collect mysql
error log
andslow query log
to logstash, I mount host volume/data/logs/mysql
to the container/var/log/mysql
:My docker-compose.yml:
and my conf/log.cnf:
but the container
exited with code 0
. The container runs up when I remove the- /data/logs/mysql:/var/log/mysql
configuration;OS: CentOS 7
MySQL: 5.7.10
The text was updated successfully, but these errors were encountered: