"invalid volume specification: ':/var/lib/mysql'" when deploying multicontainer app with mysql to a web application

THOMAS POUDROUX 25 Reputation points
2023-10-25T11:29:18.61+00:00

Hello,

I'm trying to deploy a multicontainer app, which contains 2 images : one for my api, and one for a mysql database.

Here is my docker-compose file :

version: '3.8'
networks:
    restapi:
services:
    api:
        container_name: api
        image: <custom-image>:latest
        environment:
            ...
        depends_on:
            - mysql-server
        networks:
            - restapi
        ports:
            - "8080:80"
    mysql-server:
        container_name: mysql-server
        image: mysql:latest
        environment:
            ...
        networks:
            - restapi
        ports:
            - "8082:3306"
        volumes:
            -  ${WEBAPP_STORAGE_HOME}/mysql-data:/var/lib/mysql
       


To deploy it, I created a webapp ressource, and configured it to compose this docker-compose file. When deploying it, I get the following error :

2023-10-25T11:06:22.029Z ERROR - Container create failed for dockersqlapi_mysql-server_0_790d19a3 with System.AggregateException, One or more errors occurred. (Docker API responded with status code=InternalServerError, response={"message":"invalid volume specification: ':/var/lib/mysql'"} ) InnerException: Docker.DotNet.DockerApiException, Docker API responded with status code=InternalServerError, response={"message":"invalid volume specification: ':/var/lib/mysql'"}

At first I thought it could be that ${WEBAPP_STORAGE_HOME} was not set, but it should still return '/mysql-data:/var/lib/mysql' instead of ':/var/lib/mysql'.

Yet, here is my configuration :

User's image

How is my volume specification invalid ? Do I need an additional resource ?

Thank you for your help, I will gladly give additional informations if needed, please let me know.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,408 questions
0 comments No comments
{count} votes

Accepted answer
  1. brtrach-MSFT 15,866 Reputation points Microsoft Employee
    2023-10-25T23:27:02.77+00:00

    @THOMAS POUDROUX t seems like there is an issue with the volume specification in your docker-compose file. The error message "invalid volume specification: ':/var/lib/mysql'" indicates that the volume specification is not correct.

    In your docker-compose file, you have specified the volume as follows:

    volumes:
        -  ${WEBAPP_STORAGE_HOME}/mysql-data:/var/lib/mysql
    

    The error message suggests that the volume specification is invalid because it is missing the source path.

    To fix this issue, you can try specifying the source path explicitly. For example, you can modify the volume specification as follows:

    volumes:
        -  ${WEBAPP_STORAGE_HOME}/mysql-data:/var/lib/mysql:rw
    

    Here, we have added the ":rw" option to specify that the volume should be mounted as read-write.

    If this does not work, you can try specifying the source path explicitly as well. For example:

    volumes:
        -  /path/to/mysql-data:/var/lib/mysql:rw
    

    Here, we have replaced ${WEBAPP_STORAGE_HOME} with the actual path to the mysql-data directory.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful