【问题标题】:Unable to mount volume in azure app service?无法在 Azure 应用服务中挂载卷?
【发布时间】:2019-12-19 16:26:41
【问题描述】:

我正在尝试通过 docker 容器在 azure app 服务上部署 Node SDK。在我的 sdk 中,我已经安装了一个连接文件并为此编写了一个 docker-compose。但是当我通过 azure 部署它时,出现以下错误。

InnerException:Docker.DotNet.DockerApiException,Docker API 响应 状态码=InternalServerError,响应={“消息”:“无效 卷规范:':/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 存在于此路径 /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

请告诉我是什么问题?

【问题讨论】:

    标签: amazon-web-services azure docker azure-app-service-plans


    【解决方案1】:

    更新:

    问题是您无法将文件挂载到持久存储,它应该是一个目录。所以正确的音量应该设置如下:

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

    您还需要通过设置环境变量WEBSITES_ENABLE_APP_SERVICE_STORAGE=TRUE 为容器启用Web 应用程序中的持久存储。详情请见Add persistent storage

    持久性存储仅用于持久化容器中的数据。如果您想将文件共享到容器,我建议您将 Azure 文件共享挂载到容器。但是这里需要注意注意事项:

    将 Web 应用程序中的现有目录链接到存储帐户将 删除目录内容。

    因此,您需要将 Azure 文件共享挂载到没有必要文件的新目录。您可以在Configure Azure Files in a Container on App Service 中获取有关步骤的更多详细信息。它不仅支持 Windows 容器,还支持 Linux 容器。

    【讨论】:

    • 仍然遇到问题 InnerException: Docker.DotNet.DockerApiException,Docker API 响应状态码=InternalServerError, response={"message":"invalid volume specification: ':/usr/src/app'" }
    • @DhirajKumar 你运行 Linux 镜像吗?可以在环境变量中开启持久化存储吗?
    • 我在创建应用服务时选择了linux
    • @DhirajKumar 你能分享你使用的镜像的 Dockerfile 吗?
    • 检查 docker 文件
    猜你喜欢
    • 2017-09-19
    • 1970-01-01
    • 1970-01-01
    • 2017-10-02
    • 1970-01-01
    • 1970-01-01
    • 2015-10-01
    • 2021-05-26
    • 2021-06-25
    相关资源
    最近更新 更多