'Volumes doesnt work in windows containers Docker

I want to run a mysql container in windows server 2019. For that, Im using this image: vdkhiem/advancedmysqlcore:5.7.27

When I use this docker-compose file it works fine:

    version: "3.7"

    services:
      mysql:
        image: dshatohin/mysql-servercore
        container_name: mysql
        environment:
          MYSQL_ROOT_PWD: secret
          DB_NAME: db
          DB_USER: user
          DB_USER_PWD: secret

but when I try to use volumes it doesn't work. This is the docker-compose file that I use:

    version: "3.7"

    services:
      mysql:
        image: dshatohin/mysql-servercore
        volumes:
          - C:\mysql-data:C:\MySQL\DATA
        container_name: mysql
       environment:
          MYSQL_ROOT_PWD: secret
          DB_NAME: db
          DB_USER: user
          DB_USER_PWD: secret

    volumes:
      mysql-data:

I get this error:

    + Start-Service MySQL
    + ~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OpenError: (System.ServiceProcess.ServiceControl
    ler:ServiceController) [Start-Service], ServiceCommandException
    + FullyQualifiedErrorId : StartServiceFailed,Microsoft.PowerShell.Commands
    .StartServiceCommand

    VERBOSE: Creating database db
    ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
    VERBOSE: Changing MySQL root password
    ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)

    ERROR: Failed to start or query status of service 'mysql' error [80004005]

    Service 'mysql' has been stopped

I have already check that C:\MySQL\DATA is where data is stored.

Thanks in advance.



Sources

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

Source: Stack Overflow

Solution Source