无法在 Azure 应用程序服务中挂载卷?
Unable to mount volume in azure app service?
我正在尝试通过 docker 容器在 Azure 应用服务上部署 Node SDK。在我的 sdk 中,我已经安装了一个连接文件并为此编写了一个 docker-compose。但是,当我通过 azure 部署它时,出现以下错误。
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 出现在这条路径 /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
请告诉我这是什么问题?
更新:
问题是无法将文件挂载到持久存储,它应该是一个目录。所以正确的卷应该设置如下:
volumes:
- ${WEBAPP_STORAGE_HOME}/site/wwwroot:/usr/src/app
并且您还需要通过设置环境变量 WEBSITES_ENABLE_APP_SERVICE_STORAGE=TRUE
在 Web 应用程序中为容器启用持久存储。有关详细信息,请参阅 Add persistent storage。
持久存储仅用于持久保存容器中的数据。如果您想将文件共享到容器,我建议您将 Azure 文件共享挂载到容器。但是需要注意这里的注意事项:
Linking an existing directory in a web app to a storage account will
delete the directory contents.
因此您需要将 Azure 文件共享挂载到一个没有必要文件的新目录。您可以在 Configure Azure Files in a Container on App Service 中获得有关步骤的更多详细信息。它不仅支持 Windows 个容器,还支持 Linux 个容器。
我正在尝试通过 docker 容器在 Azure 应用服务上部署 Node SDK。在我的 sdk 中,我已经安装了一个连接文件并为此编写了一个 docker-compose。但是,当我通过 azure 部署它时,出现以下错误。
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 出现在这条路径 /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
请告诉我这是什么问题?
更新:
问题是无法将文件挂载到持久存储,它应该是一个目录。所以正确的卷应该设置如下:
volumes:
- ${WEBAPP_STORAGE_HOME}/site/wwwroot:/usr/src/app
并且您还需要通过设置环境变量 WEBSITES_ENABLE_APP_SERVICE_STORAGE=TRUE
在 Web 应用程序中为容器启用持久存储。有关详细信息,请参阅 Add persistent storage。
持久存储仅用于持久保存容器中的数据。如果您想将文件共享到容器,我建议您将 Azure 文件共享挂载到容器。但是需要注意这里的注意事项:
Linking an existing directory in a web app to a storage account will delete the directory contents.
因此您需要将 Azure 文件共享挂载到一个没有必要文件的新目录。您可以在 Configure Azure Files in a Container on App Service 中获得有关步骤的更多详细信息。它不仅支持 Windows 个容器,还支持 Linux 个容器。