In a container, I am trying to start mysqld.
I was able to create an image and push to the registry but when I want to start it, the /var/lib/mysql
volume can't be initialized as I try to do a chown mysql
on it and it is not allowed.
I checked docker specific solutions but for now I couldn't make any work.
Is there a way to set the right permissions on a bind-mounted folder from bluemix? Or is the option --volumes-from
supported, I can't seem to make it work.
The only solution I can see right now is running mysqld as root, but I would rather not.
Try with mount-bind
- created a volume on bluemix using
cf ic volume create database
try to run
mysql_install_db
on my db container to initialize it's contentdocker run --name init_vol -v database:/var/lib/mysql registry.ng.bluemix.net/<namespace>/<image>:<tag> mysql_install_db --user=mysql
mysql_install_db
is supposed to populate the /var/lib/mysql
and set the rights to the owner set in the --user
option, but I get:
chown: changing ownership of '/var/lib/mysql': Permission denied.
I also tried the above in different ways, using sudo or a script. I tried with mysql_install_db --user=root
, which does setup my folder correctly, except it is owned by the root user, and I would rather keep mysql running as the mysql user.
Try with volumes-from data container
I create a data container with a volume
/var/lib/mysql
docker run --name db_data -v /var/lib/mysql registry.ng.bluemix.net/<namespace>/<image>:<tag> mysql_install_db --user=mysql
I run my db container with the option
--volumes-from
docker run --name db_srv --volumes-from=db_data registry.ng.bluemix.net/<namespace>/<image>:<tag> sh -c 'mysqld_safe & tail -f /var/log/mysql.err'
docker inspect db_srv
shows:
[{ "BluemixApp": null, "Config": { ..., "WorkingDir": "", ... } ... }]
cf ic logs db_srv
shows:
150731 15:25:11 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 150731 15:25:11 [Note] /usr/sbin/mysqld (mysqld 5.5.44-0ubuntu0.14.04.1-log) starting as process 377 .. /usr/sbin/mysqld: File './mysql-bin.index' not found (Errcode: 13) 150731 15:25:11 [ERROR] Aborting
which is due to --volumes-from
not being supported, and to data created in the first not staying in the second run.