在Azure App Service中使用Docker容器时装入卷 [英] Mount a volume while using a docker container in Azure App Service

查看:205
本文介绍了在Azure App Service中使用Docker容器时装入卷的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Azure上部署了 Web应用,并使用公共注册表中的Docker容器(我自己的图像)托管我的网站。但是用户可以上传图片,并且数据存储在服务器上的json文件中。当然,我想将这些文件写入容器外部的安装卷。这样我就可以重新部署网站的更新版本而不会丢失数据。

I've deployed a Web App on Azure and use a Docker Container from the public registry (my own image) to host my website. But users can upload pictures and data is stored in json-files on the server. Of course I want to write these files to a mounted volume outside of the container. So that I can redeploy an update version of my website without losing data.

使用Web Apps可以吗?还是我需要使用Azure上的Docker迁移到Ubuntu VM?我对Web应用程序的喜欢是,我不必担心管理虚拟机而只关心我的容器。

Is that possible with Web Apps? Or do I need to move on to an Ubuntu VM with Docker on Azure? What I like about the webapps is I don't have to worry about managing the VM and only care about my container.

推荐答案

这篇博文是一个很好的开始,并了解了Azure在卷安装方面的策略( ASL ==
Linux上的应用程序服务; ASW = Windows上的App Services
):

This blog post is a great start and understanding Azure's strategy regarding volume mounting (ASL == App Services on Linux; ASW=App Services on Windows):


...但是,在这种情况下,我们希望利用常规的App Service文件系统,因此我们可以使用FTP与应用程序进行交互。部署容器后,ASL将ASW上的D:\home路径等效安装到/ home(使用Docker中的卷安装)。现在,当发生这种情况时,由您的容器将相应的路径映射到应用程序中。为了进一步了解它的工作原理,请查看ASL上PHP7容器中使用的官方Dockerfile。

... However, in this case, we would like to leverage the regular App Service Filesystem, so we can interact with the application using FTP. When a container is deployed, ASL mounts the equivalent of D:\home path on ASW to /home (using volume mount in Docker). Now when that happens, it is up to your container to map the corresponding paths into the application. In order to understand how this works more closely, take a look at the official Dockerfile used in PHP7 container on ASL.

https:// hajekj .net / 2016/12/25 / building-custom-docker-images-for-use-in-app-service-on-linux /

这篇关于在Azure App Service中使用Docker容器时装入卷的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆