skip to Main Content

B”H

I’d like to use Azure web apps to host staging servers for wordpress.
The best way to ensure that staging is as close as possible to live seems to be docker.

I use docker-compose on my dev machine and it works great. I would like to replicate that setup on azure.

My docker-compose.yml file sets up three containers 1) mysql 2) phpMyAdmin 3) my-wordpress-container

I mount three volumes

      - ./data/mysql:/var/lib/mysql
      - ./data/init/:/docker-entrypoint-initdb.d

in the db container and

      - ./site/wp-content/uploads:/var/www/html/wp-content/uploads

in the wordpress container.

Most important is the /docker-entrypoint-initdb.d file for bootstrapping the db with test data.

How would I accomplish that in Azure web apps?


Before answering… Please do not explain how to deploy multiple containers on App services using docker-compose. Or post links to tutorials on hosting WordPress in that environment. That is both simple and not quite enough for it to be useful.

Also, please do not post links about mounting File Shares in web apps. That is also quite simple.

The question is how to mount File Shares into a multi container setup. Specifically how I might be able to mount the /docker-entrypoint-initdb.d to bootstrap the db with test data.

This is totally doable in Container Instances. However there are other features that make it unusable for this solution.

3

Answers


  1. There is a way to mount disks from Azure web apps, just google “mount disk from azure web app”. There is a good blog post from TOM KERKHOVE.

    However, I would advise you against this, currently the Azure Storage REST API appears more stable https://learn.microsoft.com/en-us/rest/api/storageservices/

    Login or Signup to reply.
  2. Azure Web-Apps enables multi-containers in preview at the moment. Web-Apps does come with MySql as part of the instance. But not recommended for when you want to scale you Web-Application. So it is best to host the MySQL in MySQL as a service.

    If you go to the link below it will walk you how to host WordPress and Redis within Azure Web-App with multi-containers. Using My-SQL Service for the database and persistent storage.

    https://learn.microsoft.com/en-gb/azure/app-service/containers/tutorial-multi-container-app

    If you would still want to run MySQL in docker you may want to consider using Azure Kubernetes Service to host all the containers instead.

    I hope this helps.

    Login or Signup to reply.
  3. I think this documentation is what you are looking for:
    https://learn.microsoft.com/en-us/azure/app-service/containers/how-to-serve-content-from-azure-storage#use-custom-storage-in-docker-compose

    From the docs:

    Azure Storage can be mounted with multi-container apps using the custom-id. To view the custom-id name, run az webapp config storage-account list --name <app_name> --resource-group <resource_group>.

    In your docker-compose.yml file, map the volumes option to custom-id. For example:

    wordpress:
      image: wordpress:latest
      volumes:
      - <custom-id>:<path_in_container>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search