How to mount docker volume in Azure Web App for containers?

元气小坏坏 提交于 2020-12-31 17:53:09

问题


I'm trying to run KrakenD image in Azure App Service.

KrakenD requires json config file krakend.json to be put into /etc/krakend/ (KrakenD image is based on Linux Alpine)

I created Web App for containers with the following docker-compose file:

version: "3"
services:
  krakend:
    image: devopsfaith/krakend:latest
    volumes:
      - ${WEBAPP_STORAGE_HOME}/site/krakend:/etc/krakend
    ports:
      - "8080:8080"
    restart: always

Added storage account with a blob container where uploaded sample kraken.json file

In app configuration i added a path mapping like this:

But it looks like volume was not mounted correctly

2019-11-15 12:46:29.368 ERROR - Container create failed for krakend_krakend_0_3032a936 with System.AggregateException, One or more errors occurred. (Docker API responded with status code=InternalServerError, response={"message":"invalid volume specification: ':/etc/krakend'"} ) (Docker API responded with status code=InternalServerError, response={"message":"invalid volume specification: ':/etc/krakend'"} ) InnerException: Docker.DotNet.DockerApiException, Docker API responded with status code=InternalServerError, response={"message":"invalid volume specification: ':/etc/krakend'"}

2019-11-15 12:46:29.369 ERROR - multi-container unit was not started successfully

Additional questions

  1. What does mean Mount path in Storage mounting? - i put there value /krankend

  2. volume definition starts with ${WEBAPP_STORAGE_HOME} in docs they specified it as

    volumes: - ${WEBAPP_STORAGE_HOME}/site/wwwroot:/var/www/html

so i did it by analogy and tried all 3 possible paths

${WEBAPP_STORAGE_HOME}/site/wwwroot/krakend
${WEBAPP_STORAGE_HOME}/site/krakend
${WEBAPP_STORAGE_HOME}/krakend

but no luck - still getting the error

ERROR parsing the configuration file: '/etc/krakend/krakend.json' (open): no such file or directory


回答1:


finally resolved that with the following docker-compose file

version: "3"
services:
  krakend:
    image: devopsfaith/krakend:latest
    volumes:
      - volume1:/etc/krakend
    environment:
     WEBSITES_ENABLE_APP_SERVICE_STORAGE: TRUE
    ports:
      - "8080:8080"
    restart: always

where volume1 is a blob storage mounted as the following




回答2:


This did not work for me. I was getting Bind mount must start with ${WEBAPP_STORAGE_HOME}.

This worked. docker-compose.yml

version: "3"
services:

  backend:
    image: xxxx
    ports:
      - 80:80
    volumes:
      - vol1:/var/www/html/public

volumes: 
   vol1:
      driver: local

Volume definition:

  • Name: vol1
  • Config: basic
  • Storage accounts: ...
  • Storage container: ...
  • Mount paht: /var/www/html/public


来源:https://stackoverflow.com/questions/58878134/how-to-mount-docker-volume-in-azure-web-app-for-containers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!