Search code examples
azuredockerazure-app-service-plans

Unable to mount volume in azure app service?


I am trying to deploy a Node SDK on azure app service through docker container. In my sdk, I have mounted a connection file & written a docker-compose for this. But when I deploy it by azure I get below error.

InnerException: Docker.DotNet.DockerApiException, Docker API responded with status code=InternalServerError, response={"message":"invalid volume specification: ':/usr/src/app/connection.json'"}

docker-compose.yml

version: '2'

services:
  node:
    container_name: node
    image: dhiraj1990/node-app:latest
    command: [ "npm", "start" ]
    ports:
      - "3000:3000"
    volumes:
      - ${WEBAPP_STORAGE_HOME}/site/wwwroot/connection.json:/usr/src/app/connection.json

connection.json is present at this path /site/wwwroot.

Dockerfile

FROM node:8

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install
# If you are building your code for production
# RUN npm ci --only=production

# Bundle app source
COPY . .

EXPOSE 3000

Please tell me what is the issue ?


Solution

  • Update:

    The problem is that you cannot mount a file to the persistent storage, it should be a directory. So the correct volumes should set like below:

    volumes:
          - ${WEBAPP_STORAGE_HOME}/site/wwwroot:/usr/src/app
    

    And you also need to enable the persistent storage in your Web app for the container by setting the environment variable WEBSITES_ENABLE_APP_SERVICE_STORAGE=TRUE. For more details, see Add persistent storage.

    The persistent storage is just used to persist your data from your container. And if you want to share your files to the container, I will suggest you mount the Azure File share to the container. But you need to pay attention to the caution here:

    Linking an existing directory in a web app to a storage account will delete the directory contents.

    So you need to mount the Azure File Share to a new directory without necessary files. And you can get more details about the steps in Configure Azure Files in a Container on App Service. It not only supports Windows containers but also supports Linux containers.