Can't prove that this is your problem, but I was having a lot of problems getting the MySQL server up and running. It seemed to be a permissions problem ... but my permissions all seemed to be OK. Here's what I did to solve it:
1) You want to be able to view the log files from your docker image after it's quit out. To do so, commit a new version with a new entry-point so that you can start it up with a bash shell:
- docker ps -a to find your image
- docker commit {container id from above} yourname/test
- docker run -it --entrypoint=bash ...all the params you set originally... yourname/test
- that'll give you a shell in the image.
2) Once you're in, check /var/log/mysql/error.log for the last run (or for simplicity, delete error.log, and then re-run mysql with "service start mysql", to get a clean error log). If you see a warning that you can't write to the directory ... you have a permissions problem
3) Now to solve your problem.
0) I assume it's not a basic permissions problem -- but just in case, check all the permissions around that path.
a) If you put your data directory in an unusual place (/home, /usr, etc.) then you may have a problem with MariaDB itself deciding not to write. Look up ProtectHome and ProtectSystem settings (Google it). But really, it's easier to move the directory as otherwise you'll need to be patching the docker.
b) (this is what my problem was) On the host system, you may have a problem with SELinux or AppArmor (my problem) protecting that location. Good guides to fixing are here for SELinux (
https://blogs.oracle.com/jsmyth/selinux-and-mysql) and here for AppArmor (
https://blogs.oracle.com/jsmyth/apparmor-and-mysql) (in brief for the latter, need to add some lines at the end of the AppArmor config for mysql in the host.