Docker percona (mysql mariadb) container stops after running on ubuntu when volume (-v) defined Docker percona (mysql mariadb) container stops after running on ubuntu when volume (-v) defined docker docker

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

  1. 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
  2. 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
  3. I login to container: docker exec -it percona /bin/bash
  4. I type: cd /var/lib
  5. 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 is mysql and group is root.
  6. I get mysql user UID by id -u mysql (I get 1001)
  7. I check by groups mysql that mysql has one group (root). So to get root GID I type id -g mysql (I get 0)
  8. The chown command allow to set file UID:GID even for users which doesnt exist (!) so we not need to create user mysql on host. So after run chown ... on host, folder files have exact the same user and group that mysql inside container expect.