'Docker container tomsik86/xampp volume creation causes the MYSQL server to fail on start up

I am very new to Docker and wanted to persist the data in my project for obvious reasons. I have created a volume to persist my database when I down the container, but the mysql fails when I do this. My yml file:

services:
  xampp:
      image: tomsik68/xampp
      ports:
          - 80:80
          - 3306:3306
          - 8080:8080
      volumes:
          - ./:/opt/lampp/htdocs/myapp/
          - ../persistence/ciblog:/opt/lampp/var/mysql/

When I start the server I get the following error from phpmyAdmin:

Cannot connect: invalid settings.
mysqli::real_connect(): (HY000/2002): Connection refused
Connection for controluser as defined in your configuration failed.
mysqli::real_connect(): (HY000/2002): Connection refused
phpMyAdmin tried to connect to the MySQL server, and the server rejected the 
connection. You should check the host, username and password in your configuration and 
make sure that they correspond to the information given by the administrator of the 
MySQL server.

The docker-compose error:

    xampp_1  | /opt/lampp/bin/mysql.server: 263: kill: No such process
    xampp_1  |

The local directory that I created with the volume is getting the correct files copied into it at start:

    Code\persistence\ciblog>ls
    0c3dbcd27851.err  aria_log.00000001  d21c59a7c20d.err  ib_logfile0  ibdata1
    ad4d7d1416ef.err  aria_log_control   ib_buffer_pool    ib_logfile1  mysql.sock

Thank you for your time!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source