Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Persisting content across docker restart within an Azure Web App

I'm trying to run a ghost docker image on Azure within a Linux Docker container. This is incredibly easy to get up and running using a custom Docker image for Azure Web App on Linux and pointing it at the official docker hub image for ghost.

Unfortunately the official docker image stores all data on the /var/lib/ghost path which isn't persisted across restarts so whenever the container is restarted all my content get's deleted and I end up back at a default ghost install.

Azure won't let me execute arbitrary commands you basically point it at a docker image and it fires off from there so I can't use the -v command line param to map a volume. The docker image does have an entry point configured if that would help.

Any suggestions would be great. Thanks!

like image 433
Adam Cooper Avatar asked Aug 24 '17 13:08

Adam Cooper


People also ask

How do I make my Docker container persistent?

Docker has two ways to achieve persistence: volume mounts, and bind mounts. Bind mounts allow you to mount a particular location on your server's filesystem to a location inside the Docker container. This link can be read-only, but also read/write, where files written by the Docker container will persist on disk.

How do you persist data in a container?

By creating a volume and attaching, or mounting, it to the folder that the data is stored in, you can persist the data. The container writes to the todo. db file and that data persists to the host in the volume. For this section, use a named volume.

Why do I lose data if Docker restarts?

Yes, once your container ceases to exist or you restart it, the data will be lost. But that can be easily fixed if you use persistent volumes to store your data. My preferred solution is to use a container orchestrator like Swarm, Kubernetes, etc. I'll expand on volumes in Kubernetes a little bit.

What happens when you restart a Docker container?

It does the equivalent of docker stop . It sends SIGTERM to its primary process (only); if that doesn't terminate within 10 seconds, it sends SIGKILL. If the primary process still has children, they also get forcibly terminated.


1 Answers

Set WEBSITES_ENABLE_APP_SERVICE_STORAGE to true in appsettings and the home directory would be mapped from your outer kudo instance:

https://docs.microsoft.com/en-us/azure/app-service/containers/app-service-linux-faq

like image 58
Max Mustermann Avatar answered Oct 21 '22 11:10

Max Mustermann