Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mount a volume while using a docker container in Azure App Service

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.

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.

like image 248
riezebosch Avatar asked May 04 '17 06:05

riezebosch


People also ask

How do I mount a volume in running Docker container?

Cloning From An Existing Container But, if you do need to add a volume to a running container, you can use docker commit to make a new image based on that container, and then clone it with the new volume. Then, you can run the new image, replacing the old image with the cloned one.

How do I mount the volume of an Azure container instance?

To mount multiple volumes in a container instance, you must deploy using an Azure Resource Manager template, a YAML file, or another programmatic method. To use a template or YAML file, provide the share details and define the volumes by populating the volumes array in the properties section of the file.

Can you mount a volume while building your Docker image?

When building an image, you can't mount a volume. However, you can copy data from another image! By combining this, with a multi-stage build, you can pre-compute an expensive operation once, and re-use the resulting state as a starting point for future iterations.

How do you attach volumes to a container?

To mount a data volume to a container add the --mount flag to the docker run command. It adds the volume to the specified container, where it stores the data produced inside the virtual environment. Replace [path_in_container] with the path where you want to place the data volume in the container.


1 Answers

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):

... 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/

like image 99
Randy Larson Avatar answered Oct 16 '22 00:10

Randy Larson