简体   繁体   English

Docker 卷行为与 azure webapp

[英]Docker volumes behavior with azure webapp

When specifying a docker volume in a dockerfile, docker creates a volume when the container is started.在 dockerfile 中指定 docker 卷时,docker 在容器启动时创建一个卷。 As expected the directories that are defined are there when logged into the container at the expected paths.正如预期的那样,当以预期路径登录到容器时,定义的目录就在那里。 However, when using the same image in Azure Webapp for Linux, while logging into the container, the expected paths and files are not there.但是,当在 Linux 的 Azure Webapp 中使用相同的图像时,在登录容器时,预期的路径和文件不存在。

Does azure webapp not support this or is there some setting that I'm missing and need to enable? azure webapp 是否不支持这个,或者是否有一些我缺少的设置需要启用? I'm not talking of mounting a filesystem/storage account as documented here .我不是在谈论安装文件系统/存储帐户,如此所述。

That won't work.那行不通的。 The alternative is to enable Persistent Storage and create a Docker Compose file where you specify a volume even if you have a single container.另一种方法是启用持久存储并创建一个Docker Compose文件,您可以在其中指定一个卷,即使您只有一个容器也是如此。 You then use the multi-container option and upload the YAML file.然后使用多容器选项并上传 YAML 文件。

Enable persistent storage by setting the application setting WEBSITES_ENABLE_APP_SERVICE_STORAGE = TRUE .通过设置应用程序设置WEBSITES_ENABLE_APP_SERVICE_STORAGE = TRUE启用持久存储。 You can do this from the portal or by using the CLI.您可以从门户或使用 CLI 执行此操作。

az webapp config appsettings set -g myResourceGroup -n <app-name> --settings WEBSITES_ENABLE_APP_SERVICE_STORAGE=TRUE

The ${WEBAPP_STORAGE_HOME} environment variable will point to the /home folder of the VM running your container. ${WEBAPP_STORAGE_HOME}环境变量将指向运行容器的 VM 的/home文件夹。 Use it to map the folder with a volume.用它来 map 带卷的文件夹。

version: '3.3'
services:
   wordpress:
     image: myimage
     volumes:
      - ${WEBAPP_STORAGE_HOME}/site/wwwroot:/var/www/html
     ports:
       - "80:80"
     restart: always

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM