Docker percona (mysql mariadb) container stops after running on ubuntu when volume (-v) defined
Solution
Type following commands on your host:
cd /home/myuser/dbsudo chown 1001:0 files
Then run container again and thats all :)
Way
- After fail of running, I look on logs:
docker logs percona
and see that mysql has no permissions to write to dir/var/lib/mysql
- I run container without volume:
docker run --name percona -e MYSQL_ROOT_PASSWORD=secret -p 6603:3306 -d percona/percona-server:latest mysql -h docker_host_ip -P 6603
- I login to container:
docker exec -it percona /bin/bash
- I type:
cd /var/lib
- After execute
ls -l
i see near mysql dir following row:drwxr-xr-x 5 mysql root 4096 Oct 6 14:39 mysql
. This mean that owner ismysql
and group isroot
. - I get mysql user UID by
id -u mysql
(I get 1001) - I check by
groups mysql
that mysql has one group (root). So to get root GID I typeid -g mysql
(I get 0) - The
chown
command allow to set file UID:GID even for users which doesnt exist (!) so we not need to create usermysql
on host. So after runchown ...
on host, folderfiles
have exact the same user and group that mysql inside container expect.