5

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!

Adam Cooper
  • 8,077
  • 2
  • 33
  • 51

5 Answers5

3

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

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

Max Mustermann
  • 351
  • 2
  • 12
  • I used this, but still after few days I see my data was lost somehow.. so this is not reliable or production ready – Krunal Oct 30 '20 at 11:54
2

You have a few options:

  1. You could mount a file share inside the Docker container by creating a custom image, then storing data there. See these docs for more details.
  2. You could switch to the new container instances, as they provide volume support.
  3. You could switch to the Azure Container Service. This requires an orchestrator, like Kubernetes, and might be more work than you're looking for, but it also offers more flexibility, provides better reliability and scaling, and other benefits.
Paul Shealy
  • 734
  • 3
  • 8
  • Thanks, option 1 looks like it might have some potential although I'm assuming I then need to bake my file share access key into the docker build which makes it impossible to share with anyone. – Adam Cooper Aug 25 '17 at 12:08
  • 1
    You didn't mention sharing in your question, so it's hard to understand your scenario, but you might specify the file share key as an environment variable so that others can specify their own key. – Paul Shealy Aug 25 '17 at 15:47
  • You're right I didn't I was just thinking if I was going to build a custom dockerfile for this I'd want to be able to share it. I'm going to try out creating a custom image with an environment variable and see how that works. – Adam Cooper Aug 26 '17 at 12:12
1

You have to use a shared volume that map the content of the container /var/lib/ghost directory to a host directory. This way, your data will persist in your host directory.

To do that, use the following command.

$ docker run -d --name some-ghost -p 3001:2368 -v /path/to/ghost/blog:/var/lib/ghost/content ghost:1-alpine
kstromeiraos
  • 4,659
  • 21
  • 26
1

I never worked with Azure, so I'm not 100 percent sure the following applies. But if you interface docker via the CLI there is a good chance it applies.

Persistency in docker is handled with volumes. They are basically mounts inside the container's file system tree to a directory on the outside. From your text I understand that you want store the content of the inside /var/lib/ghost path in /home/site/wwwroot on the outside. To do this you would call docker like this:

$ docker run [...] -v /var/lib/ghost:/home/site/wwwroot ghost

fzgregor
  • 1,807
  • 14
  • 20
  • Unfortunately I'm not running from the command line, updated my question to clarify – Adam Cooper Aug 24 '17 at 13:41
  • To bad. I found this in the Docker for Azure documentation: https://docs.docker.com/docker-for-azure/persistent-data-volumes/ – fzgregor Aug 24 '17 at 13:45
  • Thanks, but I'm not using swarm I'm using an Azure Web App on Linux: https://learn.microsoft.com/en-us/azure/app-service-web/app-service-linux-using-custom-docker-image – Adam Cooper Aug 24 '17 at 13:50
  • Looking at their CLI command documentation It seems they do not offer volume support yet. https://learn.microsoft.com/en-us/cli/azure/container – fzgregor Aug 24 '17 at 14:02
0

Unfortunately setting the persistent storage (or bring your own storage) to a specific path is currently not supported in Azure Web Apps on Linux. That's said, you can play with ssh and try and configure ghost to point to /home/ instead of /var/lib/. I have prepared a docker image here: https://hub.docker.com/r/elnably/ghost-on-azure that adds the ssh capability the dockerfile and code can be found here: https://github.com/ahmedelnably/ghost-on-azure/tree/master/1/alpine.

try it out by configuring you web app to use elnably/ghost-on-azure:latest, browse to the site (to start the container) and go to the ssh page .scm.azurewebsites.net, to learn more about SSH check this link: https://aka.ms/linux-ssh.

Ahmed Elnably
  • 461
  • 3
  • 5
  • Thanks, that's super helpful. I've actually used a similar strategy where I've just taken a stock Node image and then connected to ssh via the scm and modified the container from there. I'm going to try mounting a file share and then installing into there from a custom image and see how I get on. – Adam Cooper Aug 26 '17 at 12:19
  • These links are dead now. – Vince Bowdren Jul 30 '21 at 16:00